第10週目プロジェクト3班長情報を格納する学生類(1)
1793 ワード
/*copyright(c)2016.
* All rights reserved,
* :text.Cpp
* :
* :2016 4 30
* :vc++6.0
* :
*/
#include<iostream>
using namespace std;
class Stu //
{
public:
Stu(int n, string nam ); //
void display( ); // ,
protected: //(*)
int num; //
string name; //
};
Stu::Stu(int n,string nam)
{
num=n;
name=nam;
}
void Stu::display( )
{
cout<<" :"<<num<<endl;
cout<<" :"<<name<<endl;
}
class StuDetail: public Stu // StuDetail
{
public:
// nam, n,a , ad, nam1, n1
StuDetail(int n, string nam,int a, string ad,int n1, string nam1); //
void show( ); // ,
void show_monitor( ); // ,
private:
Stu monitor; // , , Stu
int age; //
string addr; //
};
StuDetail::StuDetail(int n, string nam,int a, string ad,int n1, string nam1):Stu(n,nam),monitor(n1,nam1),age(a),addr(ad){}
void StuDetail::show( )
{
cout<<" :"<<endl;
cout<<" :"<<num<<endl;
cout<<" :"<<name<<endl;
cout<<" :"<<age<<endl;
cout<<" :"<<addr<<endl<<endl;
}
void StuDetail::show_monitor( )
{
cout<<" :"<<endl;
monitor.display();
}
int main( )
{
// ,10010 ,19 , , , 10001
StuDetail s(10010,"Wang-li",19,"115 Beijing Road,Shanghai",10001,"Li-sun");
s.show( ); //
s.show_monitor(); //
return 0;
}