C++ "invalid constructor"

Viewed 4113

when I am trying to create a class which has a constructor which takes an object of that class by value, like for example:

class X{
    X(){}
    X(X x){} //Error!
};

then g++ complains the following for the second constructor:

error: invalid constructor; you probably meant ‘X (const X&)’

Dear compiler, no, I did not mean a const reference. This time, I wanted to do what I wrote: to pass the parameter x by value! Why is this invalid?

3 Answers
Related