C++ Interview Questions

Bjarne-stroustrup
 
Prev12 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"; }
};

class C {
public:
	C() { std::cout << "c"; }
	~C() { std::cout << "C"; }
};

A a;
int main() {
	C c;
	B b;
}

Answer