What happens when you attempt to compile and run the following code?
#include
using namespace std;
class A {
public:
int x;
A() { x=0;}
};
class B : protected A {
public:
int y;
using A::x;
B(int y) {this?>y = y;}
void Print() { cout << x << y; }
};
int main () {
B b(5);
b.Print();
return 0;
}
Which code, inserted at line 10, generates the output "2?1"?
#include
#include
using namespace std;
class A {
protected:
int y;
public:
int z;
};
//insert code here
public:
void set() {
y = 2;
z = 3;
}
void Print() { cout << y << z; }
};
int main () {
B b;
b.set();
b.z = ?1;
b.Print();
return 0;
}
What is the output of the program?
#include
#include
using namespace std;
int main () {
string s1 = "Hello", s2 = "World";
s2 = s1 + s2;
cout << s2;
return 0;
}
What is the output of the program if character 4 is supplied as input?
#include
using namespace std;
int main () {
int c;
cin >> c;
try
{
switch (c)
{
case 1:
throw 20;
case 2:
throw 5.2f;
case 3:
throw 'a';
default:
cout<<"No exception";
}
}
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;
}
Which code, inserted at line 19, generates the output "23"?
#include
#include
using namespace std;
class A {
int x;
protected:
int y;
public:
int z;
A() { x=1; y=2; z=3; }
};
class B : public A {
string z;
public:
int y;
void set() { y = 4; z = "John"; }
void Print() {
//insert code here
}
};
int main () {
B b;
b.set();
b.Print();
return 0;
}
Sarah Hernandez
15 days agoBrenda Martin
1 month agoMark Moore
2 months agoLisa Bailey
2 months agoCynthia Bailey
3 months agoJohn Moore
3 months agoJohn White
3 months agoSandra Ramirez
3 months agoDennis Wilson
2 months agoMelissa Flores
3 months agoGeorge Moore
3 months agoPaz
4 months agoGussie
4 months agoColette
4 months agoYolande
4 months agoDaniel
5 months agoDominga
5 months agoKarina
5 months agoLuisa
5 months agoQueenie
6 months agoPaul
6 months agoEliz
6 months agoRoyal
6 months agoShawnda
7 months agoTonja
7 months agoLucy
7 months agoMaybelle
8 months agoIsadora
8 months agoPrincess
8 months agoWeldon
8 months agoPaola
8 months agoBok
9 months agoBecky
9 months agoStephania
9 months agoCatarina
9 months agoHaley
10 months agoDell
10 months agoWhitley
11 months agoStephaine
11 months agoLazaro
1 year agoCeola
1 year agoAlecia
1 year agoThomasena
1 year agoHannah
1 year agoRonny
2 years agoEttie
2 years agoBrittni
2 years agoTijuana
2 years agoStephania
2 years agoIlene
2 years agoNoel
2 years agoShawna
2 years agoDonte
2 years agoMiss
2 years agoAretha
2 years agoRikki
2 years agoNickolas
2 years agoBobbye
2 years agoLeota
2 years agoDona
2 years agoStefania
2 years agoWalton
2 years agoGlory
2 years agoShawna
2 years agoTequila
2 years agoCordelia
2 years agoChuck
2 years agoBeckie
2 years ago