在我撰写C++接口课程时,我选择了以下两个选项中的任何一个。
class Interface
{
public:
virtual R1 f1(p11, p12 , ...) = 0;
...
virtual Rn fn(pn1, pn2 , ...) = 0;
virtual ~Interface() {}
}
或
class Interface
{
public:
virtual R1 f1(p11, p12 , ...) = 0;
...
virtual Rn fn(pn1, pn2 , ...) = 0;
virtual ~Interface() = 0;
}
Interface::~Interface() {}
The first version is sh或ter to write
The second is attractive in that all functions of the interface are pure virtual
Is there any reason I should prefer one 或 the other method (或 perhaps a third one)?
Thanks