抽象类中是否可以进行把本抽象类作为形参引用
class A{
public:
A();
~A();
virtual int testfunc()=0;
int operator <(A a);
};
编译出错:
cannot declare parameter `a ' to be of type `A ' because the following virtual functions are abstract
[解决办法]
int operator <(const A & a) const;
[解决办法]
引用参数
[解决办法]
int operator <(const A & a) const;
[解决办法]
virtual int testfunc() const =0;
作为一个 <比较,它应该是严格的const的。
[解决办法]
虚函数,自己不能调啊
[解决办法]
要用的话要用引用或指针。否则就成了递归定义