【发布时间】:2014-02-26 19:56:15
【问题描述】:
我看不出我的代码有什么问题。我有一个 std::vector,它是我的类 Foo 的私有成员。它没有被声明为 const,即使编译器给出的错误提示也是如此。
(在 Foo.h)
private:
std::vector<std::string> tableBackup;
我正在调用一个函数(来自 Foo.cpp):
BackupTable(this->tableBackup);
这个方法在DatabaseLoad.cpp和.h中:
public:
void BackupTable(std::vector<std::string> &tableBackup);
定义为:
void DatabaseLoad::BackupTable(std::vector<std::string> &tableBackup){
//whatever...
}
当我从 Foo.cpp 调用方法时出现以下错误:
No matching function for call to 'DatabaseLoad::BackupTable(const std::vector<std::basic_string<char> > &)'
有什么问题?目前使用 C++11,但我想这与此无关。
【问题讨论】:
-
既然已经是会员了,为什么还要传给函数呢?顺便说一句,这是关于
const -
@billz,那里有两个类。
-
也显示调用成员函数(我敢打赌它是
const-qualified)。