我有一个变量f声明为vector :: iterator,我指向c_str(),因为我试图从目录中读取文件。代码首先编译,但我的函数都没有被调用。我可以编写我的类和函数来允许我传递它并在另一个函数中使用它: 这是int main()中代码的一部分。
int main() {
vector<string> files;
if (d) {
//we successfully opened the directory
//while there's still something we haven't looked at
while ((dir = readdir(d)) != NULL) {
//get the name of that thing
string filename = dir->d_name;
//filter out what we don't want
if (filename == "." || //filter out current dir
filename == ".." || //filter out parent dir
filename.find(".csv") == string::npos) //here is where you set up the match
continue;
//and add what we do want to our files data structure
files.push_back(basepath + "/" + filename);
}
}
map<string, int> foo;
double fail = 0;
for (vector<string>::iterator f = files.begin(); f != files.end(); ++f) {
Extract_Organize process;
cout << "What";
process.transform();
process.create_file();
cout << "Finished!\n";
}
return 0;
}
class Extract_Organize {
public:
Extract_Organize;
void transform();
void create_file();
string double_integrate(int, int);
};
#endif
答案 0 :(得分:1)
我猜这个问题是:
Extract_Organize process();
什么时候应该
Extract_Organize process;
StackOverflow上有关于最烦恼的解析的吨问题,但最重要的是你的代码声明了一个名为process
的函数而不是创建对象Extract_Organize
。