我对C++很新,当我尝试调用create_event_file()函数时,我得到以下错误'fw'不是主文件中的类或命名空间.
这是我的代码.
#ifndef FILE_WRITER_H
#define FILE_WRITER_H
#include <string>
using namespace std;
class File_Writer{
private:
int test;
public:
File_Writer() { }
void create_event_file(void);
void write(const string file_name, string data);
};
#endif // FILE_WRITER_H
Run Code Online (Sandbox Code Playgroud)
cpp文件
#include "file_writer.h"
#include <iostream>
#include <fstream>
using namespace std;
File_Writer::File_Writer(void){
cout << "Object of File_Writer is created" << endl;
}
void File_Writer::create_event_file(void){
ofstream outputFile;
outputFile.open("event.txt");
string data;
cout << "Enter event title : " << endl;
getline(cin,data);
outputFile << textToSave;
cout << "Enter event date : " …
Run Code Online (Sandbox Code Playgroud) c++ ×1