What is the output of the following program?
#include <iostream>
using namespace std;
class TestClass
{
private:
int val;
void showVal()
{ cout << val << endl; }
public:
TestClass(int x)
{ val = x; }
};
int main()
{
TestClass test(77) ;
test.showVal() ;
return 0;
}
A) The program runs, but with no output.
B) 77
C) 0
D) The program will not compile.
Correct Answer:
Verified
Q2: More than one constructor function may be
Q7: More than one destructor function may be
Q8: You must declare all data members of
Q21: For the following code, which statement
Q23: What is the output of the
Q23: This is automatically called when an object
Q30: What is the output of the
Q31: The process of object-oriented analysis can be
Q33: In a procedural program you typically have
Q44: The constructor function always has the same
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents