What happens when you attempt to compile and run the following code?
What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; class A { public: int x; A() { x=0;} }; class B : public A { public: B() { x=1;} }; class C : private B { public: C() { x=2;} }; int...
What will be the output of the program?
What will be the output of the program? #include <iostream> using namespace std; int fun(int); int main() { cout << fun(5); return 0; } int fun(int i) { return i*i; }A . 25 B.5 C.0 D.1View AnswerAnswer: A
What happens when you attempt to compile and run the following code?
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)...
What happens when you attempt to compile and run the following code?
What happens when you attempt to compile and run the following code? #include <iostream> #include <string> using namespace std; int f(int i, int b); int main() { int i=0; i++; for (i=0; i<=2; i++) { cout<<f(0,i); } return 0; } int f(int a, int b) { return a+b; }A ....
What happens when you attempt to compile and run the following code?
What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; #define DEF_A 0 #define DEF_B DEF_A+1 #define DEF_C DEF_B+1 int main(int argc, char *argv[]) { cout << DEF_C; return 0; }A . It prints: 2 B.It prints: 10 C.It prints: 0 D.It prints:...
What is the output of the program?
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 ); }A . It prints: WorldHello B.It prints: HelloWo C.It prints: World D.It prints: HelloView AnswerAnswer:...
What happens when you attempt to compile and run the following code?
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,z; A() : x(1), y(2), z(0) { z = x + y; } A(int a, int b) : x(a), y(b) { z =...
What happens when you attempt to compile and run the following code?
What happens when you attempt to compile and run the following code? #include <iostream> #include <string> using namespace std; class First { string *s; public: First() { s = new string("Text");} ~First() { delete s;} void Print(){ cout<<*s;} }; int main() { First FirstObject; FirstObject.Print(); FirstObject.~First(); }A . It prints:...
obj?
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"; }...
B(int x) {this?
What happens when you attempt to compile and run the following code? #include <iostream> #include <string> using namespace std; class A { public: int x; }; class B : public A { public: B() { x=1;} B(int x) {this?>x = x;} }; int main () { B c1; B c2(10);...