Page 1 of 1

What happens when you attempt to compile and run the following code?#include <iostream>#include <string>using namespace

Posted: Wed Aug 03, 2022 9:20 am
by answerhappygod
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;}

A. It prints: 010
B. It prints: 110
C. It prints: 00
D. It prints: 1