Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> All rights reserved.

All rights reserved.

編輯:關於Android編程

[cpp] 
/* 
* Copyright (c) 2013, 煙台大學計算機學院                     
* All rights reserved.                     
* 文件名稱:test.cpp                     
* 作者:樊露露                    
* 完成日期:2013 年 5 月 27 日                     
* 版本號:v1.0                   
*                     
* 輸入描述:無                     
* 問題描述:                  
* 程序輸出:
* 問題分析:                    
* 算法設計:略                     
*/          
#include<iostream>  
#include<string>  
using namespace std; 
class Teacher 

public: 
    Teacher(string n,int a,char s,string ad,string t,string ti); 
    void display(); 
private: 
    string name; 
    int age; 
    char sex; 
    string add; 
    string tel; 
    string title; 
}; 
Teacher::Teacher(string n,int a,char s,string ad,string t,string ti):name(n),age(a),sex(s),add(ad),tel(t),title(ti){ }   
void Teacher::display()   
{   
    cout<<"name:"<<name<<endl;   
    cout<<"age:"<<age<<endl;   
    cout<<"sex:"<<sex<<endl;   
    cout<<"title:"<<title<<endl;   
    cout<<"address:"<<add<<endl;   
    cout<<"tel:"<<tel<<endl;   
}   
 
class Cadre 

public: 
    Cadre(string n,int a,char s,string ad,string t,string p); 
    void display(); 
private: 
    string name; 
    int age; 
    char sex; 
    string add; 
    string tel; 
    string post; 
}; 
Cadre::Cadre(string n,int a,char s,string ad,string t,string p) 

    name=n; 
    age=a; 
    sex=s; 
    add=ad; 
    tel=t; 
    post=p; 

void Cadre::display() 

    cout<<"name:"<<name<<endl;   
    cout<<"age"<<age<<endl;   
    cout<<"sex:"<<sex<<endl;   
    cout<<"post:"<<post<<endl;   
    cout<<"address:"<<add<<endl;   
    cout<<"tel:"<<tel<<endl; 

 
class Teacher_Cadre:public Teacher,public Cadre   

public: 
    Teacher_Cadre(string n,int a,char s,string ad,string t,string ti,string p,int w); 
    void show(); 
private: 
    string name; 
    int age; 
    char sex; 
    string add; 
    string tel; 
    int wages; 
}; 
Teacher_Cadre::Teacher_Cadre(string n,int a,char s,string ad,string t,string ti,string p,int w):Teacher(n,a,s,ad,t,ti),Cadre(n,a,s,ad,t,p),wages(w){ } 
void Teacher_Cadre::show() 

    Teacher::display(); 
    //cout<<"post:"<<Cadre::post<<endl;  
    cout<<"wages:"<<wages<<endl; 

 
int main() 

    Teacher_Cadre te_ca("Wang-li",50,'f',"135 Beijing Road,Shanghai","(021)61234567","president","prof.",1534);   
    te_ca.show( );   
    return 0;   

/*
* Copyright (c) 2013, 煙台大學計算機學院                    
* All rights reserved.                    
* 文件名稱:test.cpp                    
* 作者:樊露露                   
* 完成日期:2013 年 5 月 27 日                    
* 版本號:v1.0                  
*                    
* 輸入描述:無                    
* 問題描述:                 
* 程序輸出:
* 問題分析:                   
* 算法設計:略                    
*/        
#include<iostream>
#include<string>
using namespace std;
class Teacher
{
public:
 Teacher(string n,int a,char s,string ad,string t,string ti);
 void display();
private:
 string name;
 int age;
 char sex;
 string add;
 string tel;
 string title;
};
Teacher::Teacher(string n,int a,char s,string ad,string t,string ti):name(n),age(a),sex(s),add(ad),tel(t),title(ti){ } 
void Teacher::display() 

    cout<<"name:"<<name<<endl; 
    cout<<"age:"<<age<<endl; 
    cout<<"sex:"<<sex<<endl; 
    cout<<"title:"<<title<<endl; 
    cout<<"address:"<<add<<endl; 
    cout<<"tel:"<<tel<<endl; 

class Cadre
{
public:
 Cadre(string n,int a,char s,string ad,string t,string p);
 void display();
private:
 string name;
 int age;
 char sex;
 string add;
 string tel;
 string post;
};
Cadre::Cadre(string n,int a,char s,string ad,string t,string p)
{
 name=n;
 age=a;
 sex=s;
 add=ad;
 tel=t;
 post=p;
}
void Cadre::display()
{
 cout<<"name:"<<name<<endl; 
    cout<<"age"<<age<<endl; 
    cout<<"sex:"<<sex<<endl; 
    cout<<"post:"<<post<<endl; 
    cout<<"address:"<<add<<endl; 
    cout<<"tel:"<<tel<<endl;
}

class Teacher_Cadre:public Teacher,public Cadre 
{
public:
 Teacher_Cadre(string n,int a,char s,string ad,string t,string ti,string p,int w);
 void show();
private:
 string name;
 int age;
 char sex;
 string add;
 string tel;
 int wages;
};
Teacher_Cadre::Teacher_Cadre(string n,int a,char s,string ad,string t,string ti,string p,int w):Teacher(n,a,s,ad,t,ti),Cadre(n,a,s,ad,t,p),wages(w){ }
void Teacher_Cadre::show()
{
 Teacher::display();
 //cout<<"post:"<<Cadre::post<<endl;
 cout<<"wages:"<<wages<<endl;
}

int main()
{
 Teacher_Cadre te_ca("Wang-li",50,'f',"135 Beijing Road,Shanghai","(021)61234567","president","prof.",1534); 
    te_ca.show( ); 
    return 0; 
}
 \

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved