我有以下类结构:
class MyBase
{
public:
virtual ExportData exportData() = 0;
virtual bool exportData(QString filepath)
{
ExportData data = exportData();
data.save(filepath);
}
};
class MyClass : public MyBase
{
public:
virtual ExportData exportData(){//some implementation}
};
class MySubClass : public MyClass
{
public:
virtual ExportData exportData(){//some implementation}
};
然后我导出数据如下:
MySubClass *sub = new MySubClass();
sub->exportData("/home/me/export.xml");
尝试使用 g++ 编译时,出现以下错误:
error: no matching function for call to ‘MySubClass::exportData(QString)’
note: candidate is: virtual ExportData MySubClass::exportData()
note: candidate expects 0 arguments, 1 provided
我没有看到我做错了什么,为什么会这样?