What will the variable "age" be in class B?

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; } };A . publicB . privateC . protectedD . None of theseView...

January 7, 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; struct { int x; char c; union { float f; int i; }; } s; int main (int argc, const char * argv[]) { s.x=10; s.i=0; cout << s.i << " " <<...

January 6, 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 { 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 =...

January 6, 2024 No Comments READ MORE +

Which code, inserted at line 14, generates the output "3.14 10"?

Which code, inserted at line 14, generates the output "3.14 10"? #include <iostream> using namespace std; namespace myNamespace1 { int x = 5; int y = 10; } namespace myNamespace2 { float x = 3.14; float y = 1.5; } int main () { //insert code here cout << x...

January 6, 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; 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 main ()...

January 6, 2024 No Comments READ MORE +

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

January 6, 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 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:...

January 6, 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 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; }A...

January 6, 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 <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: 0B . It prints:...

January 6, 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 B; class A { int age; public: A () { age=5; }; friend class B; }; class B { string name; public: B () { name="Bob"; }; void Print(A ob)...

January 5, 2024 No Comments READ MORE +