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:
10
Please complement the member functions of the sample class. Member variables cannot be added.
#include <iostream>using namespace Std;class sample{public: int v; sample (int n): V (n) {}//to supplement your code here};int main () { Sample a (5); Sample B = A; cout << B.V; return 0;}
Input
No
Output
10
Sample input
No
Sample output
10
1#include <iostream>2 using namespacestd;3 classsample{4 Public:5 intv;6Sample (intN): V (n) {}7Sample (Sample &a) {8v =2*A.V;9 }Ten }; One intMain () { ASample A (5); -Sample B =A; -cout <<B.V; the return 0; -}
POJ C + + Programming programming Jobs-class and Object programming questions # #