Answer This question is compilable and deterministic. Its output is "B". Explanation The "trick" here is that B::f() is called even though i
Continue ReadingC++ Interview Question 16 Answer
Answer This question is compilable and deterministic. Its output is "abBA". Explanation The base class constructor is called before the inhe
Continue ReadingC++ Interview Question 15 Answer
Answer This question is compilable and deterministic. Its output is "abBA". Explanation Member variables are initialized before the construc
Continue ReadingC++ Interview Question 14 Answer
Answer This question is compilable and deterministic. Its output is "acabBA". Explanation Static local variables are initialized the first t
Continue ReadingC++ Interview Question 13 Answer
Answer This question is compilable and deterministic. Its output is "abcBCA". Explanation §3.6.2¶4 in the standard: "It is implementation
Continue ReadingC++ Interview Question 12 Answer
Answer This question is compilable and deterministic. Its output is "acbBCA". Explanation §3.6.2¶4 in the standard: "It is implementation
Continue ReadingC++ Interview Question 11 Answer
Answer This question is compilable and deterministic. Its output is "0". Explanation Since a is a static local variable, it is automatically
Continue ReadingC++ Interview Question 10 Answer
Answer This question is compilable and deterministic. Its output is "0". Explanation Since a has static storage duration and no initializer,
Continue ReadingC++ Interview Question 9 Answer
Answer This question is compilable and deterministic. Its output is "428". Explanation When f() is called with a as both parameters, both ar
Continue ReadingC++ Interview Question 8 Answer
Answer This question is compilable and deterministic. Its output is "A". Explanation g(A a) takes an object of type A by value, not by refer
Continue Reading