Hi, I'm using g++ version 3.4.2 and the following program behaves strangly: class A { public: A(bool b) : b_(b) {} A(const A& a) { b_ = !a.b_; } bool get() const { return b_; } private: bool b_; };
#include <iostream> using namespace std; int main() { A x = A(A(true)); cout << x.get() << endl; } It outputs 1 rather than 0, specifically the copy constructor is not called. Changing A x = A(A(true)); to A y = A(true); A z = A(y); cout << z.get() << endl; outputs 0. WHY??? _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus