我有这个CSVParser类,我继承了,需要调用<<
我的派生类中的运算符:
#include "dbcsv.h"
DbCsv::DbCsv() : CSVParser()
{
}
void addColumn(QString &source, const QString &val, const unsigned int s) // 0:duplicate, 1:unique
{
CSVParser::<< source.toStdString();
}
void removeColumn(QString &source, const QString &val)
{
}
我收到这个错误:
dbcsv.cpp: In function 'void addColumn(QString&, const QString&, unsigned int)':
dbcsv.cpp:10: error: expected unqualified-id before '<<' token
dbcsv.cpp: At global scope:
最佳答案
在 <<
之前与 operator
并附加括号。制作operator<<(whatever)
.
这适用于其他移位运算符和其他运算符重载。
关于c++ - 如何在派生类中调用基类的<<运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14787859/