MoreExam
1. Question Content...
EXPLANATION
Answer: X - EXPLANATION Content.
Question1: What will the variable "age" be in class B?class A {int x;protected:int y;public:int age;A () { age=5; };};class B : public A {string name;public:B () { name="Bob"; };void Print() {cout << name << age;}};
Question2: 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";}};int main(){B ob2;A *obj;obj = &ob2;obj->Print();}
Question3: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;#define DEF_A 0int main(int argc, char *argv[]) {cout << DEF_A;return 0;}
Question4: 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 = u.tab[0];y = u.tab[1];cout << x << "," << y << "," << u.i;return 0;}
Question5: 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(2), y(2), z(1) { z = x + y; }A(int a, int b) : x(a), y(b) { z = x + y;}void Print() { cout << z; }};class B : public A {public:int y;B() : A() {}B(int a, int b) : A(a,b) {}void Print() { cout << z; }};int main () {A b;b.Print();return 0;}
Question6: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;class First{public:First() { cout << "Constructor";}void Print(){ cout<<"from First";}};int main(){First FirstObject;FirstObject.Print();}
Question7: 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) {}A(int a, int b) : x(a), y(b) { z = x * y;}void Print() { cout << z; }};class B : public A {public:int y;B() : A() {}B(int a, int b) : A(a,b) {}void Print() { cout << z; }};int main () {A b(2,5);b.Print();return 0;}
Question8: What happens when you attempt to compile and run the following code?#include <iostream> #include <string> using namespace std;const int size = 3; class A {public:string name;A() { name = "Bob";}A(string s) { name = s;}A(A &a) { name = a.name;}};class B : public A {public:int *tab;B() { tab = new int[size]; for (int i=0; i<size; i++) tab[i]=1;}B(string s) : A(s) { tab = new int[size]; for (int i=0; i<size; i++) tab[i]=1;}~B() { delete tab; }void Print() {for (int i=0; i<size; i++) cout << tab[i];cout << name;}};int main () {B b1("Alan");B b2;b1.tab[0]=0;b1.Print(); b2.Print();return 0;}
Question9: 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) {cout << name << ob.age;}};int main () {A a;B b;b.Print(a);return 0;}
Question10: Which code, inserted at line 12, generates the output "5b"?#include <iostream> using namespace std; namespace myNamespace1 { int var = 5; } namespace myNamespace2 { char var = 'b'; } int main () { //insert code here return 0; }
Question11: 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";}
Question12: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int main(){int *t;t = new int[2];for (int i=0; i<2; i++) {t[i]=0;}cout << t[1];}
Question13: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int x=5;static int y=0;void myFunction(int a){y=++a;}int main (int argc, const char * argv[]){int i=0;myFunction(i);cout<<y<<" "<<x;}
Question14: 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 : public A {public:B() { cout << "B no parameters";}B(string s) { cout << "B string parameter";}B(int s) { cout << "B int parameter";}};int main () {A a2("Test");B b1(10);B b2(b1);return 0;}
Question15: What happens when you attempt to compile and run the following code?#include <iostream>#include <string>using namespace std;class SampleClass{string *s;public:SampleClass() { s = new string("Text");}SampleClass(string s) { this->s = new string(s);}~SampleClass() { delete s;}void Print(){ cout<<*s;}};int main(){SampleClass *obj;obj = new SampleClass("Test");obj->Print();}
Question16: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int main(){int x=0;int *ptr;ptr = &x; cout<<x<<" "<<*ptr;return 0; }
Question17: What happens when you attempt to compile and run the following code?#include <iostream> #include <string>using namespace std;int main(){string s1[]= {"How" , "to" };s1[0].swap(s1[1]);for (int i=0; i<2; i++) {cout << s1[i];}return( 0 );}
Question18: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;void fun(char*);int main(){char t[4]={'0', '1', '2', '3'};fun(&t[0]);return 0;}void fun(char *a){cout << *a;}
Question19: Which code, inserted at line 8, generates the output "100"?#include <iostream>using namespace std;int fun(int);int main(){int *x = new int;*x=10;//insert code herereturn 0;}int fun(int i){return i*i;}
Question20: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int fun(int x) {return x<<2;}int main(){ int i;i = fun(1) / 2;cout << i;return 0;}
Question21: Given:#include <iostream>#include <exception>using namespace std;int main () {try{int * myarray= new int[1000];}catch (bad_alloc&){ cout << "Error allocating memory"; } catch (exception& e) { cout << "Standard exception"; } catch (...) { cout << "Unknown exception"; } return 0; }What will happen if we use the operator "new" and the memory cannot be allocated?
Question22: 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(){BaseClass o(10);fun(o);o.Print();}void fun(BaseClass x) {cout << "Hello:";}
Question23: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;class BaseC{public:int *ptr;BaseC() { ptr = new int(10);}BaseC(int i) { ptr = new int(i); }~BaseC() { delete ptr; }};void fun(BaseC x);int main(){BaseC *o = new BaseC(5);fun(*o);}void fun(BaseC x) {cout << "Hello:"<<*x.ptr;}
Question24: What is the output of the program if characters 'h', 'e', 'l', 'l' , 'o' and enter are supplied as input?#include <iostream> #include <string>using namespace std;void f();int main(){f();return 0;}void f(){char c;c = cin.get();cout << c;if(c != '\n')f();}
Question25: 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 C:public A {public:virtual void Print()=0;};int main(){C obj3;obj3->Print();}
Question26: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;class complex{double re;double im;public:complex() : re(0),im(0) {}complex(double x) { re=x,im=x;};complex(double x,double y) { re=x,im=y;}void print() { cout << re << " " << im;}};int main(){complex c1;c1.print();return 0;}
Question27: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int main(){int i = 4;while(i >= 0) {cout<<i;i??;}return 0;}
Question28: What is the output of the program?#include <iostream>#include <string>using namespace std;int main(){string s1="World";string s2;s2="Hello" + s1;cout << s2;return( 0 );}
Question29: What is the output of the program?#include <iostream>#include <string>using namespace std;int main(){char str[] = "Hello\0\World\0";cout << str;return 0;}
Question30: Which of the following structures are correct?1:struct s1{ int x; char c;};2:struct s2{ float f; struct s2 *s;};3:struct s3{ float f; in i;}
Question31: Which code, inserted at line 10, generate the output "50"?#include <iostream>using namespace std;class Base {int age;public:Base () {age=5;};//insert code herevoid Print() { cout << age;}};void setAge(Base &ob) {ob.age = 0;}int main () {Base a;a.Print();setAge(a);a.Print();return 0;}
Question32: What happens when you attempt to compile and run the following code?#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 () {namespace newname = myNamespace1;using namespace newname;cout << x << " ";cout << y;return 0;}
Question33: What happens when you attempt to compile and run the following code?#include <iostream> using namespace std;int main(){int i = 1;if (--i==1) {cout << i;} else {cout << i-1;}return 0;}
Question34: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int main(){union un{int x;char c;};union un u1 = {10};union un u2 = {'a'};union un u3 = {20, 'a'};cout<<u1.x;cout<<u2.c;cout<<u3.c;return 0;}
Question35: What happens when you attempt to compile and run the following code?#include <iostream>#include <string>using namespace std;class A {int x;protected:int y;public:int z;};class B : public A {string name;public:void set() {y = 2;z = 3;}void Print() { cout << y << z; }};int main () {B b;b.set();b.Print();return 0;}
Question36: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;void fun(int*);int main(){int *x;int i=2;x=&i;fun(x);cout<<i;return 0;}void fun(int *i){*i = *i * *i;}
Question37: What will happen when you attempt to compile and run the following code?#include <iostream>using namespace std;int getValue();int main(){const int x = getValue();cout<<x;return 0;}int getValue(){return 5;}
Question38: Point out an error in the program.#include <iostream>using namespace std;int main(){char s1[] = "Hello";char s2[] = "world";char *const ptr = s1;*ptr = 'a';ptr = s2;return 0;}
Question39: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int fun(int x) {return 2*x;}int main(){int i;i = fun(1) || fun(2);cout << i;return 0;}
Question40: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int main(){int a=5;cout << ((a < 5) ? 9.9 : 9);}
Question41: What happens when you attempt to compile and run the following code?#include <iostream>#include <string>using namespace std;int f(int i);int main(){int i=0;i++;for (i=0; i<=2; i++){cout<<f(i);}return 0;}int f(int a){return a+a;}
Question42: 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;}
Question43: What is the output of the program?#include <iostream>using namespace std;#define PRINT(i) cout<<i;int main(){int y=2, z=3;PRINT(y);PRINT(z);return 0;}
Question44: What is the output of the program?#include <iostream> #include <string>using namespace std;union t { char c; int i; };class First { union t u; public: First() {u.c = 'A';}void Print(){cout << u.c;}};int main(){First *t = new First();t->Print();}
Question45: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int main(int argc, char *argv[]) {char *s = "ABCDEF";cout << s+2;return 0;}
Question46: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int main(){int i = 1;if (i++==1) {cout << i;} else {cout << i-1;}return 0;}
Question47: What is the output of the program if characters 't', 'e', 's' and 't' enter are supplied as input?#include <iostream> #include <string>using namespace std;int main(){string s;getline( cin, s );cout << s << " " << s.length();return( 0 );}
Question48: 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();}
Question49: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int min(int a, int b);int main(){int b=10;b = min(5,20);cout << b;return 0;}int min(int a, int b){if (a<b)return(a);elsereturn(b);}
Question50: 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 Print() {cout << z;}};int main () {A a(2,5);a.Print();return 0;}
Question51: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int min(int a, int b);int main(){int min(int,int);int b;b = min(10,20);cout << b;return 0;}int min(int a, int b){return(b);}
Question52: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int main(){int i=5;switch(i){case 1:cout<<"Hello";break;case 2:cout<<"world";break;case 3:break;default:cout<<"End";}return 0;}
Question53: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int op(int x, int y){int i;i = x + y;return i;}int main(){int i=1, j=2, k, l;k = op(i, j);l = op(j, i);cout<< k << "," << l;return 0;}
Question54: What will the variable "age" be in class B?class A {int x;protected:int y;public:int age;};class B : protected A {string name;public:void Print() {cout << name << age;}};
Question55: 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 :void print() {cout << "B ";}};int main() {B sc[2];B *bc = (B*)sc;for (int i=0; i<2;i++)(bc++)->print();return 0;}
Question56: What is the output of the program if character 2 is supplied as input?#include <iostream>using namespace std;int main () {int c;cin >> c;try{switch (c){case 1:throw 20;case 2:throw 5.2f;}}catch (int e){ cout << "int exception. Exception Nr. " << e; }catch (float e){ cout << "float exception. Exception Nr. " << e; }catch (...){ cout << "An exception occurred."; }return 0;}
Question57: What will happen when you attempt to compile and run the following code?#include <iostream>#include <string>using namespace std;string fun(string, string);int main(){string s="Hello";cout << fun(s, " World");return 0;}string fun(string s1, string s2){return s1+s2;}
Question58: What is the output of the program?#include <iostream>#include <string>using namespace std;struct Person {int age;};class First{Person *person;public:First() {person = new Person;person->age = 20;}void Print(){cout << person->age;}};int main(){First t[2];for (int i=0; i<2; i++)t[i].Print();}
Question59: What happens when you attempt to compile and run the following code?#include <iostream>#include <cstdarg>using namespace std;int mult(int f, int s, int t);int main(){cout << mult(1,2,3);return 0;}int mult(int f, int s, int t) { int mult_res; mult_res = f*s*t; return mult_res; }
Question60: What happens when you attempt to compile and run the following code?#include <iostream>#include <string>using namespace std;void fun(int i);int main(){int i=0;i++;for (i=0; i<=5; i++){fun(i);}return 0;}void fun(int i){ if (i==3) return; cout << i; }
Question61: How could you pass arguments to functions?
Question62: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;class First{public:void Print(){ cout<<"from First";}};class Second{public:void Print(){ cout<< "from Second";}};int main(){Second t[2];for (int i=0; i<2; i++)t[i].Print();}
Question63: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int mul (int a, int b=2){int r;r=a*b;return (r);}int main (){cout << mul(1) << mul(2,4);return 0;}
Question64: What is the output of the program?#include <iostream>#include <string>using namespace std;int main(){string s1[]= {"H" , "t" };string s;for (int i=0; i<2; i++) {s = s1[i];if (i==0)s.insert(1,"ow");elses.push_back('o');cout << s;}return( 0 );}
Question65: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int main(){const int x=20;const int *ptr;ptr = &x;*ptr = 10;cout<<*ptr;return 0;}
Question66: What happens when you attempt to compile and run the following code?#include <iostream>#include <string>using namespace std;class Base{string s;public:Base() { s="Sample text";}Base(string s) { this->s=s; }void Print() { cout << s; }};int main(){Base *o = new Base();o->Print();}
Question67: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int main(){int i = 1;for(i=10; i>-1; i/=2) {if(!i)break;}cout << i;return 0;}
Question68: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int main() {float i = 1.0 / 2 * 2 / 1 * 2 / 4 * 4 / 2;cout << i;return 0;}
Question69: 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 << " " << s.x;}
Question70: 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 << c1.x;cout << c2.x;return 0;}
Question71: 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 = x + y;}void Print() { cout << z; }};class B : public A {public:int y;B() : A() {}B(int a, int b) : A(a,b) {}void Print() { cout << z; }};int main () {A b;b.Print();return 0;}
Question72: Which definitions are correct?
Question73: What happens when you attempt to compile and run the following code?#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 () {{using namespace myNamespace1;cout << x << " ";}{using namespace myNamespace2;cout << y;}return 0;}
Question74: What will be the output of the program?#include <iostream>using namespace std;int main(){const int y = 5;const x = ?10;cout<<x<<" "<<y;return 0;}
Question75: How many times will "HELLO" be printed?#include <iostream>using namespace std;int main(){for(int i=?1; i<=10; i++){if(i < 5)continue;elsebreak;cout<<"HELLO";}return 0;}
Question76: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int main(){int x,y=10;float f;f = 5.90;cout << f << ", ";x=f;cout << x <<", ";f=y;cout << f;return 0;}
Question77: 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;}
Question78: 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;}{int i=5;cout << i;}cout<<i;return 0;}
Question79: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;class complex{double re;double im;public:complex() : re(0),im(0) {}complex(double x) { re=x,im=x;};complex(double x,double y) { re=x,im=y;}void print() { cout << re << " " << im;}};int main(){complex c1(1,2);c1.print();return 0;}
Question80: What will happen when you attempt to compile and run the following code?#include <iostream>#include <string>using namespace std;int fun(int);int main(){int *x = new int;*x=10;cout << fun(*x);return 0;}int fun(int i){return i*i;}
Question81: What happens when you attempt to compile and run the following code?#include <iostream>#include <string>using namespace std;class complex{double re, im;public:complex() : re(1),im(0.4) {}complex operator?(complex &t);void Print() { cout << re << " " << im; }};complex complex::operator? (complex &t){complex temp;temp.re = this->re ? t.re;temp.im = this->im ? t.im;return temp;}int main(){complex c1,c2,c3;c3 = c1 ? c2;c3.Print();}
Question82: What happens when you attempt to compile and run the following code?#include <iostream>#include <string>using namespace std;int main(){string s1[]= {"H" , "t" };string s;for (int i=0; i<2; i++) {s = s1[i];s.insert(1,"o");cout << s; } return( 0 ); }
Question83: What will happen when you attempt to compile and run the following code?#include <iostream>using namespace std;int main (int argc, const char * argv[]){enum state { ok, error, warning};enum state s1, s2, s3;s1 = ok;s2 = warning;s3 = error;s4 = ok;cout << s1<< s2<< s3;return 0;}
Question84: What will be the output of the program?#include <iostream>using namespace std;int main(){int i=0;for(; i<=5; i++)cout << i;return 0;}
Question85: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int main(){const char *s;char str[] = "Hello";s = str;while(*s) {cout << *s++;}return 0;}
Question86: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;void set(struct person*);struct person{int age;};int main(){struct person e = {18};set(&e);cout<< e.age;return 0;}void set(struct person *p){p->age = p->age + 1;}
Question87: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int main(){int i = 1;if (i==1) {cout << i;} else {cout << i-1;}return 0;}
Question88: What happens when you attempt to compile and run the following code?#include <iostream>#include <string>using namespace std;class A {public:int x;A() { x=0;}};class B {public:int x;B() { x=1;}};class C :public A, public B {public:int x;C(int x) {this->x = x;
Question89: What happens when you attempt to compile and run the following code?#include <iostream> #include <string>using namespace std;class complex{double re, im;public:complex() : re(1),im(0.4) {}complex operator+(complex &t);void Print() { cout << re << " " << im; }};complex complex::operator+ (complex &t){complex temp;temp.re = this->re + t.re;temp.im = this->im + t.im;return temp;}int main(){complex c1,c2,c3;c3 = c1 + c2;c3.Print();}
Question90: What happens when you attempt to compile and run the following code?#include <cstdlib>#include <iostream>using namespace std;float* sum(float a,float b);float* sum(float a,float b){float *f = new float;*f = a+b;return f;}int main(){float a,b,*f;a = 1.5; b = 3.4;f = sum(a,b);cout<<*f;return 0;}
Question91: 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 herecout << x << " " << y;return 0;}
Question92: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;#define FUN(arg) if(arg) cout<<"Test";int main(){int i=1;FUN(i<3);return 0;}
Question93: What will be the output of the program?#include <iostream>#include <string>using namespace std;int fun(int);int main(){float k=3;k = fun(k);cout<<k;return 0;}int fun(int i){i++;return i;}
Question94: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;class First{public:virtual void Print(){ cout<<"from First";}};class Second:public First{public:void Print(){ cout<< "from Second";}};void fun(First *obj);int main(){First FirstObject;fun(&FirstObject);Second SecondObject;fun(&SecondObject);}void fun(First *obj){obj->Print();}
Question95: 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=1; y=2; z=3; }A(int a, int b) : x(a), y(b) { z = x * y;}void Print() {cout << z;}};int main () {A a(2,5);a.Print();return 0; }
Question96: What happens when you attempt to compile and run the following code?#include <iostream>#include <string>using namespace std;struct Person {string name;int age;};class First{Person *person;public:First() {person = new Person;person->name = "John";person->age = 30;}void Print(){cout<<person->name << " "<< person->age;}};int main(){First t[2];for (int i=0; i<2; i++)t[i].Print();}
Question97: What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int main(){int i, j;for(i = 0, j = 1; j < 2, i < 4; i++, j++);cout << i << " " << j; return 0;}
Question98: What will the variable "y" 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;}};
Question99: What is not inherited from the base class?
Question100: Which code, inserted at line 15, generates the output "5 Bob"?#include <iostream>#include <string>using namespace std;class B;class A {int age;public:A () { age=5; };friend void Print(A &ob, B &so);};class B {string name;public:B () { name="Bob"; };//insert code here};void Print(A &ob, B &so) {cout<<ob.age << " " << so.name;}int main () {A a;B b;Print(a,b);return 0;}