Construct object with itself as reference?
I just realised that this program compiles and runs (gcc version 4.4.5 / Ubuntu): #include <iostream> using namespace std; class Test { public: // copyconstructor Test(const Test& other); }; Test::Test(const Test& other) { if (this == &other) cout << "copying myself" << endl; else cout << "copying something else" << endl; } int main(int argv, char** argc) { Test a(a); // compiles, runs and prints "copying myself" Test *b = new Test(*b); // compiles, runs and prints "copying something else" } I wonder why on earth this even compiles. I assume that (just as in Java) arguments are evaluated