/* *copyright (c) 2016, *all Rights reserved, School of computer and Control engineering, Yantai University. * File name: main.cpp * Author: li * Completion date: May 1, 2016 * version number: v1.0 * * Problem Description: The student class that stores monitor information * Input Description: No * Output Description: Student, monitor information */#include <iost Ream> using namespace std; Class Stu//declares base class {public:stu (int n, string nam); Base class constructor void display (); member function, output base class data member Protected://(*) Access rights are protected data member int num; Student study number string name; Student name}; Stu::stu (int n, string nam) {num=n; Name=nam; } void Stu::d isplay () {cout<< "No.:" <<num<<endl<< "Name:" <<name<<endl; } class Studetail:public Stu//Declare derived class Studetail {public://student NAM, study number n,a years old, live ad, his monitor is NAM1, study number N1 StuD Etail (int n, String nam,int A, string ad,int n1, string nam1); Derived class constructor void show (); member function, output student's information void Show_monitor (); member function, the output monitor information Private:stu monitor; The class monitor of the student, the monitor is the student, is the member of the Stu class int age; Student Age string Addr; Student's address}; void StUdetail::show () {cout<< "Student information:" <<endl; Display (); cout<< "Age:" <<age<< "Address:" <<addr<<endl; cout<<endl; } void Studetail::show_monitor () {cout<< "Monitor info:" <<endl; Monitor.display (); } Studetail:: Studetail (int n, String nam,int A, string ad,int n1, String nam1): Stu (N,nam), monitor (n1,nam1) {age=a ; Addr=ad; } int main () {//Student Wang Li, No. 10,010th, 19 years old, lives in Shanghai's Beijing Road, his monitor is Jason, study number 10001 Studetail s (10010, "Wang-li", "," Beijing Road,sh Anghai ", 10001," Li-sun "); S.show (); Output Student information s.show_monitor (); Output monitor information return 0; }
11th Week "Item 2-Student Class 1" for storing monitor information