C++ Interview Questions

Bjarne-stroustrup
 
Prev15 of 17Next

According to the C++11 standard, what is the output of this program?

#include <iostream>

class A {
public:
	A() { std::cout << 'a'; }
	~A() { std::cout << 'A'; }
};

class B {
public:
	B() { std::cout << 'b'; }
	~B() { std::cout << 'B'; }
	A a;
};

int main() { B b; }

Answer