Question 41
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;}
A(int x) { this?>x=x;}
};
class B : private A {
public:
using A::x;
B() { x=1;}
B(int x) {this?>x = x;}
};
int main () {
B c1;
B c2(?5);
cout << c1.x;
cout << c2.x;
return 0;
}
#include <iostream>
#include <string>
using namespace std;
class A {
public:
int x;
A() { x=0;}
A(int x) { this?>x=x;}
};
class B : private A {
public:
using A::x;
B() { x=1;}
B(int x) {this?>x = x;}
};
int main () {
B c1;
B c2(?5);
cout << c1.x;
cout << c2.x;
return 0;
}
Question 42
What is not inherited from the base class?
Question 43
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();
}
#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();
}
Question 44
Which of the following is a logical operator?
Question 45
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
int i = 0;
i++;
goto lab;
i++;
lab:
cout<<i;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int i = 0;
i++;
goto lab;
i++;
lab:
cout<<i;
return 0;
}
