What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; class A { public: virtual void Print()=0; }; class B:public A { public: virtual void Print() { cout<< "B"; } }; class C:public A { public: virtual void Print() { cout<< "C"; } }; int main() { B ob2; C ob3; A *obj; obj = &ob2; obj?>Print(); obj = &ob3; obj?>Print(); }
Answer(s): A
What will the variable "age" be in class B? class A { int x; protected: int y; public: int age; }; class B : private A { string name; public: void Print() { cout << name << age; } };
Answer(s): B
What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int x=5; static int y; int i=0; void static myFunction() { y=x++ + ++i; } int main (int argc, const char * argv[]) { x++; myFunction(); cout<<y<<" "<<x<< " " << i; }
Answer(s): C
Which of the structures is incorrect?1:struct s1{ int x; long int li;};2:struct s2{ float f; struct s2 *s;};3:struct s3{ float f; struct s3 s;};
What is the output of the program? #include <iostream> #include <string> using namespace std; int main() { string s1="Wo"; string s2; s2 = s1; string s3; s3 = s2.append("rldHello"); cout << s3; return( 0 ); }
Post your Comments and Discuss C++ Institute CPA exam prep with other Community members: