#include <iostream> #include <string> using namespace std; class Menber{ public: char *Name; char *Sex; int Age; Menber(char n[],char s[],int a); char SetName(){ Name=name; return *Name; } char SetSex(){ Sex=sex; return *Sex; } int SetAge(){ Age=age; return Age; } private: char *name; char *sex; int age; }; Menber::Menber(char n[],char s[],int a) { name=n; sex=s; age=a; } class Teacher:public Menber{ public: Teacher(char *o,int m):Menber(Name,Sex,Age){ money=m; objection=o; } private: int money; char *objection; }; class Student:public Menber{ public: Student(int id):Menber(Name,Sex,Age){ ID=id; } private: int ID; }; void main(){ Menber m1("kjhk","m",20); cout<<m1.SetName<<endl; }
最后为什么会输出 1,而不能输出姓名?
解决方案
40
你想输出函数的地址?