Attempt History
Attempt Time Score
LATEST Attempt 1 10 minutes 10 out of 10
Answers will be shown after your last attempt
Submitted Dec 8 at 5:19pm
Question 1
pts
What is the output of the following program?
#include <iostream>
using namespace std;
class A {
public:
char c;
};
class B : A {
};
int main(void) {
B b;
A a;
a.c = b.c = '?';
cout << int(a.c - b.c) << endl;
return 0;
}
The program will cause a compilation error.
4
2
, 1
Question 2
pts
What is the output of the following program?
#include <iostream>
using namespace std;
class A {
public:
int x;
void d() { x /= 2; }
};
class B : public A {
public:
int y;
void d() { y /= 4; }
};
int main(void) {
B b;
b.x = b.y = 4;
b.d();
cout << b.x / b.y << endl;
return 0;
}
4
The program will cause a compilation error.
1
2
Attempt Time Score
LATEST Attempt 1 10 minutes 10 out of 10
Answers will be shown after your last attempt
Submitted Dec 8 at 5:19pm
Question 1
pts
What is the output of the following program?
#include <iostream>
using namespace std;
class A {
public:
char c;
};
class B : A {
};
int main(void) {
B b;
A a;
a.c = b.c = '?';
cout << int(a.c - b.c) << endl;
return 0;
}
The program will cause a compilation error.
4
2
, 1
Question 2
pts
What is the output of the following program?
#include <iostream>
using namespace std;
class A {
public:
int x;
void d() { x /= 2; }
};
class B : public A {
public:
int y;
void d() { y /= 4; }
};
int main(void) {
B b;
b.x = b.y = 4;
b.d();
cout << b.x / b.y << endl;
return 0;
}
4
The program will cause a compilation error.
1
2