Programming Question # # #
Source: POJ (Coursera statement: The exercises completed on POJ will not count against the final results of Coursera. )
Note: Total time limit: 1000ms memory limit: 65536kB
Describe
The output of the following program is:
5,5
5,5
Please fill in the blanks:
#include <iostream>using namespace Std;class Base {public: int k; Base (int n): K (n) {}};class Big {public: int v; Base b;//complements your code here};int main () { Big A1 (5); Big A2 = A1; cout << a1.v << "," << a1.b.k << Endl; cout << a2.v << "," << a2.b.k << Endl; return 0;}
Input
No
Output
5,5
5,5
Sample input
No
Sample output
5,55,5
Tips
The missing code has the following form:
Big ________________{} big ________________{}
#include <iostream>using namespacestd;classBase { Public: intK; Base (intN): K (n) {}};classBig { Public: intv; Base b; //Add your code hereBig (intN): V (n), b (n) {}; Big (Big&a): V (A.V), B (A.V) {};};intMain () {Big A1 (5); Big A2 =A1; cout<< A1.V <<","<< A1.B.K <<Endl; cout<< A2.V <<","<< A2.B.K <<Endl; return 0;}
POJ C + + Programming programming Jobs-class and Object programming Question # #