3

demo class is defined as below:

    class myclass
    {
    public:
        int i;
        myclass() :i(0)
        {   }
        myclass(const myclass& other){
            i = other.i;
            cout << " left ref ok" << endl; // prints !!!Hello World!!!
        }

    myclass(myclass&& other){
        i = other.i;
        cout << "c11 right ref ok" << endl; // prints !!!Hello World!!!
    }
};

myclass m1; 
myclass m2(std::move(m1)); // ok
myclass m3(myclass());     // wrong

both vs2015 and g++4.8 act same. gcc report : m3 is none-class type , myclass(myclass(*)())

i can't understand why this happen T.T

Eliad
  • 894
  • 6
  • 20
frank fy
  • 39
  • 3

0 Answers0