What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; #include <iostream> using namespace std; class First { public: void Print(){ cout<<"from First";} }; int main() { First t[2]; for (int i=0; i<2; i++) t[i].Print(); }
Answer(s): B
What is the output of the program given below? #include <iostream> using namespace std; int main (int argc, const char * argv[]) { int i=10; { int i=0; cout<<i; } cout<<i; return 0; }
Answer(s): C
What happens when you attempt to compile and run the following code? #include <iostream> #include <string> using namespace std; class A { public: int x; A() { x=0;} A(int x) { this?>x=x;} }; class B : private A { public: using A::x; B() { x=1;} B(int x) {this?>x = x;} }; int main () { B c1; B c2(?5); cout << c1.x; cout << c2.x; return 0; }
What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int main (int argc, const char * argv[]) { int a = 30, b = 1, c = 5, i=10; i = b < a < c; cout << i; return 0; }
Answer(s): D
What happens when you attempt to compile and run the following code? #include <iostream> #include <string> using namespace std; class B; class A { int age; public: A () { age=5; }; friend class B; }; class B { string name; public: B () { name="Bob"; }; void Print(A ob) { cout << name << ob.age; } }; int main () { A a; B b; b.Print(a); return 0; }
Answer(s): A
Post your Comments and Discuss C++ Institute CPA exam prep with other Community members:
Our website is free, but we have to fight against AI bots and content theft. We're sorry for the inconvenience caused by these security measures. You can access the rest of the CPA content, but please register or login to continue.