我是c ++的新手所以有很多我不知道的事情,这就是为什么我想问一个有更多经验的人.
std::vector<CProp*> filter(const string &deptName, const string &city, const string &country)const {
...
}
Run Code Online (Sandbox Code Playgroud)
我正在使用std命名空间,所以std ::应该是多余的,但如果我删除它,编译器会显示错误(首先是这个声明没有存储类或类型说明符?).这是为什么?我从来没有在类中的其他地方使用它,所以不应该有任何冲突我也只使用std命名空间.
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <memory>
#include <vector>
#include <algorithm>
using namespace std;
class ClassName {
public:
...
private:
vector<CProp*> vector;
vector<CProp*> filter(const string &deptName, const string &city, const string &country)const {
return nullptr;
}
}
Run Code Online (Sandbox Code Playgroud)
这定义了一个名为"vector"的成员,它与std :: vector冲突
private:
vector<CProp*> vector;
Run Code Online (Sandbox Code Playgroud)