/* (Start of program header annotation)
* Copyright and version Declaration of the program
* Copyright (c) 2011, a student from the computer College of Yantai University
* All Rights Reserved. * file name: indicates the access Qualifier and Inheritance Method by mistake.
* Prepared by: BAO Zengkai
* Completion date: January 1, May 21, 2012
* Version No.: vc.1
* Description of tasks and Solutions
* Input description:
* Problem description:
Understanding the access qualifier of the base class members and the Inheritance Method of the derived class
It is inherited by student1 in the following derived class to the base class student ......
(1) modify the access qualifier of the base class members and the inheritance mode of the derived class, consider possible running results or possible errors, and perform verification and Comparison on the computer, to understand the access attributes of the derived class members.
(2) Summarize (1) the results, and write (1) The results summary to the report blog; finally, summarize and determine the access attribute principles of the members of the derived class using their own words, it is also written in the report blog.
/* [Task] understands the access qualifier of the base class members and the Inheritance Method of the derived class. student1 of the derived class inherits the base class student ...... () Modify the access qualifier of the base class members and the Inheritance Method of the derived class, consider possible running results or possible errors, and perform verification and Comparison on the computer, to understand the access attributes of the derived class members. () Summarize the results of () and write the results of () to the report blog. Finally, use your own words to summarize and determine the access attribute principles of the members of the derived class, and write them to the report blog. (The code is similar to p363 example. 5. You can study this code during the preparation phase of the machine, and the experiment code is provided on the BB platform .) */# Include <iostream> # include "string" using namespace STD; class student // () modify the access qualifier of each data member and member function in the student class, and observe the phenomenon {public: Student (int n, string Nam, char S); void show ();~ Student () {} protected: int num; string name; char sex;}; Class student1: Public student // () modify the inheritance method here, and observe the phenomenon {public: student1 (int n, string Nam, char S, int A, string AD); // student (n, NAM, S ); void show1 ();~ Student1 () {} PRIVATE: int age; string ADDR;}; Student: Student (int n, string Nam, char s) {num = N; name = Nam; sex = s;} void Student: Show () {cout <"Num:" <num <Endl; cout <"Name: "<name <Endl; cout <" Sex: "<sex <Endl;} student1: student1 (int n, string Nam, char s, int A, string AD): Student (n, NAM, S) {age = A; ADDR = aD;} void student1: show1 () {cout <"Num: "<num <Endl; cout <" name: "<name <Endl; cout <" Sex: "<sex <Endl; cout <"Age:" <age <Endl; cout <"Address:" <ADDR <Endl;} int main () {student1 stud1 (10010, "Wang-li", 'F', 19, "115 Beijing Road, Shanghai"); student1 stud2 (10011, "Zhang-fun ", 'M', 21, "213 Shanghai Road, Beijing"); Student stud3 (20010, "He-xin", 'M'); stud1.show1 (); stud2.show (); stud3.show (); Return 0 ;}