Questions and codes:
/* *copyright (c) 2016, Yantai University School of computer *all rights reserved. * File name: Zwj.cpp * Author: Zhang Weijing * Completion date: May 10, 2016 * Version number: v1.0 * * Problem Description: Read program * Input Description: * Program output: */#include <iostream>using Namespa CE std;class part//Parts class {Public:part (); Part (int i); ~part ();p rivate:int Val;}; Part::P art () {val=0; cout<< "Calls the part's default constructor:" <<val<<endl;} Part::P Art (int i) {val=i; cout<< "Calls the part's constructor:" <<val<<endl;} Part::~part () {cout<< "calls the destructor for part:" <<VAL<<ENDL;} Class Whole:public part{public:whole (); Whole (Int,int,int,int); ~whole ();p Rivate:part one; part; int data;}; Whole::whole () {data=0; cout<< "Call the default constructor for whole:" <<DATA<<ENDL;} Whole::whole (int p, int i,int j,int k): part (P), one (j), II (i), data (k)//Problem 2{cout<< "Call Whole constructor:" <<da Ta<<endl;} Whole::~whole () {cout<< "calls the destructor for Whole:" <<DATA<<ENDL;} void F () {Whole W1; Whole W2 (1,2,3,4);} int main () {f (); return 0;}
Operation Result:
Process Analysis:
11th Week Reading Procedure (supplement)----(3)