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 result of the following program output is:
0
5
Please fill in the blanks:
#include <iostream>using namespace Std;class a {public: int val;//Add your code here};main () { a A; cout << a.val << Endl; A.getobj () = 5; cout << a.val << Endl;}
Input
No
Output
0
5
Sample input
No
Sample output
05
Tips
The missing code has the following form:
A (_________________) {val = n;} ________________ getobj () { return _________________; }
1#include <iostream>2 using namespacestd;3 4 classA {5 Public:6 intVal;7 //Add your code here8 Public:9Aintn =0)Ten { Oneval =N; A } -a&getobj () { - return* This; the } - }; - - intMainintargcConst Char*argv[]) { + A; -cout << A.val <<Endl; +A.getobj () =5; Acout << A.val <<Endl; at}
POJ C + + Programming programming Jobs-class and Object programming questions # #