作者在 2009-05-10 10:09:39 发布以下内容
#include<iostream>
#include<iomanip>
#include<string>
#include<stdio.h>
using namespace std;
class person
{private:
string _name;
public:
void printname();
void setname(string name){_name=name;}
};
#include<iomanip>
#include<string>
#include<stdio.h>
using namespace std;
class person
{private:
string _name;
public:
void printname();
void setname(string name){_name=name;}
};
void person::printname ()
{cout<<_name<<endl;
}
{cout<<_name<<endl;
}
class student:public person
{private:
long _number;
public:
void printinfo();
void setnum(long number){_number=number;}
};
{private:
long _number;
public:
void printinfo();
void setnum(long number){_number=number;}
};
void student::printinfo ()
{cout<<"name of student"<<endl;
person::printname ();
cout<<"number of student "<<_number<<endl;
}
{cout<<"name of student"<<endl;
person::printname ();
cout<<"number of student "<<_number<<endl;
}
class teacher:public person
{private:
long _number;
public:
void printinfo();
void setnum(long number){_number=number;}
};
{private:
long _number;
public:
void printinfo();
void setnum(long number){_number=number;}
};
void teacher::printinfo ()
{cout<<"name of teacher"<<endl;
person::printname ();
cout<<"number of teacher "<<_number<<endl;
}
{cout<<"name of teacher"<<endl;
person::printname ();
cout<<"number of teacher "<<_number<<endl;
}
int main()
{student b;
b.setname ("bai");
b.setnum(100);
b.printinfo ();
{student b;
b.setname ("bai");
b.setnum(100);
b.printinfo ();
teacher c;
c.setname ("zhang");
c.setnum(200);
c.printinfo();
c.setname ("zhang");
c.setnum(200);
c.printinfo();
return 0;
}
虽然程序很罗嗦,但还是很高兴,加油 王娇 !!!!!!! 不会辜负师傅的,我的2万行,我来啦