由于没学c,学了c++一个学期,还是有很多不懂,有段程序我拿到电脑上修改了好久都没有运行出来,不知那位大哥能否帮忙看哈运行的结果是什么,谢谢!!
#include<iostream.h>
class Person
{
int MarkAchieve;
char Name[20];
public:
Person(char *name)
{ strcpy(char *name); MarkAchieve=0;}
void SetMark(int mark)
{ MarkAchieve=mark;}
virtual void CalMark()=0
void Print()
{
cout<<Name<<"的业绩分:"<<MarkAchieve<<endl;
}
};
class Student :public Person
{
int credit,grade;
public:
Student(char *name,int cred,int grad):Person(name)
{ credit=cred;grade=grad;}
void CalMark() {SetMark(credit*grand);}
};
class Teacher:public Person
{
int classhour,studnum;
public:
Teacher(char *name,int ch,int sn):Person(name)
{ classhour=ch;studnum=sn;}
void CarMark()
{ SetMark(classhour*studnum/30);}
};
void mian()
{ Person *p1;
Student s1("hircoko",3,90);
p1=&s1;
p1->CalMark();
p1->Print();
Teacher t1("takako",50,40);
p1=&t1;
p1->CalMark();
p1->Print();
}
十万火急!!那位大哥帮哈忙