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; void fun(int &i); int main() { int i=2; fun(i); cout<<i; return 0; } void fun(int &i) { i+=2; }A . It prints: 2B . It prints: 0C . It prints: 4D . It...

January 10, 2024 No Comments READ MORE +

obj?

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 =...

January 10, 2024 No Comments READ MORE +

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); cout...

January 9, 2024 No Comments READ MORE +

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 { public: A() { cout << "A0 ";} A(string s) { cout << "A1";} }; class B: public A { public: B() { cout << "B0 ";} B(string s)...

January 9, 2024 No Comments READ MORE +

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<<...

January 9, 2024 No Comments READ MORE +

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; #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(); }A . It prints: from FirstB . It...

January 9, 2024 No Comments READ MORE +

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; int main (int argc, const char * argv[]) { int x,y; union t { char tab[2]; int i; }; union t u; u.tab[0] = 1; u.tab[1] = 2; u.i = 0; x =...

January 9, 2024 No Comments READ MORE +

What is the output of the program given below?

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; }A . 1010B . 100C . 010D . None of theseView AnswerAnswer: C

January 8, 2024 No Comments READ MORE +

What is the output of the program?

What is the output of the program? #include <iostream> using namespace std; int main() { int tab[4]={10,20,30,40}; tab[1]=10; int *p; p=&tab[0]; cout<<*p; return 0; }A . It prints: 10B . It prints: 20C . It prints: 11D . It prints: 30View AnswerAnswer: A

January 8, 2024 No Comments READ MORE +

A(string s) { this?

What happens when you attempt to compile and run the following code? #include <iostream> #include <string> using namespace std; class A { public: string s; A(string s) { this?>s = s; } }; class B { public: string s; B (A a) { this?>s = a.s; } void print() {...

January 8, 2024 No Comments READ MORE +