#include
using namespace std;
class Data
{
protected:
char name[20];
public:
Data(char*p);
void print();
};
Data::Data(char*p)
{
strcpy(name,p);
}
void Data::print()
{
cout<<"It's name is:"<
class Teacher:public Data
{
protected:
double sal;
public:
Teacher(char *p,double a);
void print();
}
Teacher::Teacher(char *p,double a): Data(p)
{
sal=a;
}
void Teacher::print()
{
Data::print();
cout<<"It's sal is :"<
}
int main()
{
Data a("wang");
Teacher b("wang",1.0);
a.print();
b.print();
return 0;
}
e:\类与类的关系\chengxu3_2.cpp(30) : error C2533: 'Teacher::Teacher' : constructors not allowed a return type
e:\类与类的关系\chengxu3_2.cpp(44) : error C2264: 'Teacher::Teacher' : error in function definition or declaration; function not called