函数重载问题,不让我重载。。
五号智能 2008-05-24 06:05:50 #include <iostream>
using namespace std;
class teacher
{
public:
teacher(char* intput_name)
{
name=new char[10];
strcpy(name,intput_name);
}
teacher()
{
name=new char[10];
strcpy(name,"None");
}
~teacher()
{
delete [] name;
cout <<"delete finshed"<<endl;
}
void show();
char* show();
protected:
char* name;
};
void teacher::show()
{
cout <<name<<endl;
}
char* teacher::show()
{
return name;
}
class student
{
public:
student(char *temp):teacher1(temp)
{
number=1;
score=100;
}
student()
{
number=1;
score=100;
}
~student()
{
cout<<"student析解"<<endl;
}
void show();
protected:
int number;
int score;
teacher teacher1;
};
void student::show()
{
cout<<teacher1.show()<<endl<<number<<" "<<score<<endl;
}
int main()
{
student a;
student b("张大民");
a.show();
b.show();
return 0;
}
为什么不让我重载!我先去吃饭,回来再说