m_lt = CLeitaiAction(); 没问题,
如果 m_lt = new CLeitaiAction();
就会binary '=' : no operator defined which takes a right-hand operand of type 'class CLeitaiAction *' (or there is no acceptable conversion)这是什么原因?
如果 m_lt = new CLeitaiAction();
就会binary '=' : no operator defined which takes a right-hand operand of type 'class CLeitaiAction *' (or there is no acceptable conversion)这是什么原因?
你想NEW 那么要将 new 的对象存入一个CLeitaiAction指针对象。CLeitaiAction *plt = new CLeitaiAction;你上面的编译器只是说你没有定义operator=()运算符。不能进行 = 付值操作!
CLeitaiAction m_lt; 在这个类的cpp文件中m_lt = new CLeitaiAction(); 就出现问题。
CLeitaiAction* m_lt;
CLeitaiAction *m_lt = new CLeitaiAction;正解m_lt = CLeitaiAction();
CLeitaiAction()返回的一般是个引用,所以也正确