Tenth week-Read the program

Source: Internet
Author: User

Read Program 5:

(5) Read the definition of the following class, say the result of a call in a different situation in the test function # include <iostream>using namespace Std;class a{protected:int a,b;public:a (i    NT AA, int bb): A (AA), B (BB) {} void PrintA () {cout<< "A:" <<a<< "\TB:" <<b<<endl; }};class b:public a{int c;public:b (int aa, int bb, int cc): A (AA,BB), C (cc) {} void Printb () {COUT&L    t;< "A:" <<a<< "\TB:" <<b<< "\TC:" <<c<<endl;    }};int Main () {a A ();    b b (2,3,4); Add the code in the following quiz return 0;}    (a) a=b;    A.printa ();    B.printa ();    B.PRINTB (); 12341234 What do you think the output is: The result of the ____________ Run program is: ____________ (b) b=a;    A.printa ();    B.printa ();    B.PRINTB (); The program will compile errors because: ____ records the errors in the IDE and understands: ___ (c) A &r1=a;    A &r2=b;    R1.printa ();    R2.printa ();    R2.PRINTB (); the wrong line will be deleted; for the rest of the program, you think the output is: ____ The actual running output is: __________ the wrong reason for that line is: ________ (d) A *p=&a;    P->printa ();    p=&b;    P->printa (); P-&GT;PRINTB (); Delete the line where the error occurred; for the rest of the program, you think the output is: __The actual output is: __________ the wrong reason for the line is: ________ (e) Adds a member function in Class A: int Geta () {return A;} adds a general function before the main function: void F (A x) {cout&lt ;< "Aaaaah, my A:" <<x.geta () <<endl;}    The specified part of the main function is: f (a); f (b); What do you think the result of the output is: ____________ The result of the Run program is: ____________
(a):

A:2 B:3

A:2 B:3

A:2 B:3 C:4

(b):

_ An object of a common derived class can be used as the object of a base class, and conversely, the ___ &NBSP;
record the errors prompted in the IDE and understand: _no Match for ' operator= ' b=a ' __ &NBSP;
(c):
The wrong reason for the line is that you cannot find the function in Class A PRINTB

(d)

The reason for the error in that line is: function Printb not found in Class A

(e)

Aaaaah, my a:1
Aaaaah, my A:2

Tenth week-Read the program

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.