Posted by: rmn on: 20/08/2009
This question was written by a friend who luckily let me use it. It presents a very common pitfall of C++, regarding the syntax of decleration statements.
In the following code, what would be the type of b?
struct A {
A (int i) {}
};
struct B {
B (A a) {}
};
int main () {
int i = 1;
B b(A(i));
return 0;
}
Hint: you will be surprised! Try printing inside B’s constructor.
Eh, the most vaxine parse
07/09/2009 at 22:05
A few good replies to this question can now be found on stackoverflow:
http://stackoverflow.com/questions/1379932/trick-question-regarding-declaration-syntax-in-c