2014-11週-プロジェクト1:班長情報を蓄積する学生類

2000 ワード

/*
*            :
*Copyright(c)2014,           
*All rights reserved.
*    :
*  :   
*    :2014  05 5 
*   :v1.0
*             :
*    :  
*    :
*    : 
*    :
*    :
*/

#include <iostream>
#include <string>
using namespace std;

class Stu   //    
{
public:
    Stu(int n, string nam )
    {
    num=n;
    name=nam;
    }//      
    void display( )
    {
       cout<<"  :"<<num<<endl<<"  :"<<name<<endl;
    }          //    ,        
protected:        //(*)             
    int num;      //    
    string name;  //    
};
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):Stu(n,nam),monitor(n1,nam1)
    {
        age=a;
        addr=ad;
    } //       
    void show( )
    {
        cout<<"     :"<<endl;
        display();
        cout<<"  :"<<age<<endl;
        cout<<"  :"<<addr<<endl<<endl;
    } //    ,       
    void show_monitor( )
    {
        cout<<"    :"<<endl;
        monitor.display();

    }    //    ,      
private:
    Stu monitor;   //        ,     , Stu    
    int age;       //    
    string addr;   //     
};
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;
}