11th Week Reading Procedure (supplement)----(3.2)

Source: Internet
Author: User

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:" &LT;&LT;VAL&LT;&LT;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:" &LT;&LT;DATA&LT;&LT;ENDL;} Whole::whole (int p, int i,int j,int k): part (P), II (i), one (j), data (k)//Problem 2{cout<< "Call Whole constructor:" <<data& Lt;<endl;} Whole::~whole () {cout<< "calls the destructor for Whole:" &LT;&LT;DATA&LT;&LT;ENDL;}    void F () {Whole W1; Whole W2 (1,2,3,4);}    int main () {f ();return 0;} 

Warning:

Reason:



The initialization order should be in the order of Declaration. Otherwise, a warning will appear.

11th Week Reading Procedure (supplement)----(3.2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.