Q.

Which of the following is true about the following program
#include <iostream> class Test
{
public:
int i;
void get();
};
void Test::get()
{
std::cout <<"Enter the value of i: "; std::cin >>i;
}
Test t; // Global object int main()
{
Test t; // local object t.get();
std::cout <<"value of i in local t: "<<t.i<<'\n';
::t.get();
std::cout <<"value of i in global t: "<<::t.i<<'\n'; return 0;
}

A. compiler error: cannot have two objects with same class name
B. compiler error in line "::t.get();"
C. compiles and runs fine
Answer» C. compiles and runs fine
788
0
Do you find this helpful?
5

Discussion

No comments yet