Which of the following can be checked in a switch?case statement?
Answer(s): A,B,C
What happens when you attempt to compile and run the following code? #include <iostream> #include <string> using namespace std; class A { int x; protected: int y; public: int z; }; class B : public A { string name; public: void set() { y = 2; z = 3; } void Print() { cout << y << z; } }; int main () { B b; b.set(); b.Print(); return 0; }
Answer(s): C
What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; class A { public: void Print(){ cout<<"A";} }; class B:public A { public: void Print(){ cout<< "B";} }; int main() { A *obj; A ob1; obj = &ob1; obj?>Print(); B ob2; obj = &ob2; obj?>Print(); }
Answer(s): B
What happens when you attempt to compile and run the following code? #include <iostream> #include <string> using namespace std; class A { protected: int y; public: int x; int z; A() { x=2; y=2; z=3; } A(int a, int b) : x(a), y(b) { z = x ? y;} void Print() { cout << z; } }; int main () { A a(2,5); a.Print(); return 0; }
Answer(s): A
What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; void fun(int*); int main() { int i=2; fun(&i); cout<<i; return 0; } void fun(int *i) { *i = *i**i; }
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.