-1

我有一个变量 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
4

1 回答 1

1

我猜问题是:

Extract_Organize process();

什么时候应该

Extract_Organize process;

StackOverflow 上有很多关于棘手的解析process的问题,但最重要的是你的代码声明了一个调用的函数而不是创建一个对象Extract_Organize

于 2012-06-21T18:16:42.520 回答