A(int a, int b) : x(a), y(b) { z = x ?

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

June 29, 2023 No Comments READ MORE +

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="Hello"; string s2="World"; s1+=s2; cout << s1; return( 0 ); }A . It prints: HelloWorld B.It prints: Hello C.It prints: World D.It prints: HelWorldView AnswerAnswer: A

June 29, 2023 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...

June 29, 2023 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 First B.It prints:...

June 29, 2023 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(){ cout<<"A";} }; class B:public A { public: void Print(){ cout<< "B";} }; int main() { A *obj; A ob1; obj = &ob1; obj?>Print(); B ob2; obj...

June 28, 2023 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 <cstdlib> #include <iostream> using namespace std; inline float sum(float a,float b) { return a+b; } int main() { float a,b; a = 1.5; b = 3.4; cout<<sum(a,b); return 0; }A . It prints: 0 B.It prints: 4.9...

June 28, 2023 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 << "A no parameters";} A(string s) { cout << "A string parameter";} A(A &a) { cout << "A object A parameter";} }; class B...

June 28, 2023 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; class BaseClass { public: int *ptr; BaseClass(int i) { ptr = new int(i); } ~BaseClass() { delete ptr; delete ptr;} void Print() { cout << *ptr; } }; void fun(BaseClass x); int main()...

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

June 27, 2023 No Comments READ MORE +

Which statement should be added in the following program to make work it correctly?

Which statement should be added in the following program to make work it correctly? using namespace std; int main (int argc, const char * argv[]) { cout<<"Hello"; }A . #include<stdio.h> B.#include<stdlib.h> C.#include <iostream> D.#include<conio.h>View AnswerAnswer: C

June 27, 2023 No Comments READ MORE +