簡単な質問かもしれませんが、私はこの問題に 1 時間半も取り組んできましたが、本当に途方に暮れています。
ここでコンパイラエラー:
synthesized method ‘File& File::operator=(const File&)’ first required here
私はこのビットのコードを持っています:
void FileManager::InitManager()
{
int numberOfFile = Settings::GetSettings()->NumberOfFile() + 1;
for( unsigned int i = 1; i < numberOfFile; i++ )
{
std::string path = "data/data" ;
path += i;
path += ".ndb";
File tempFile( path );
_files.push_back( tempFile ); // line that cause the error
/*if( PRINT_LOAD )
{
std::cout << "Adding file " << path << std::endl;
}*/
}
}
_files (このヘッダーで定義されている場合):
#pragma once
//C++ Header
#include <vector>
//C Header
//local header
#include "file.h"
class FileManager
{
public:
static FileManager* GetManager();
~FileManager();
void LoadAllTitle();
private:
FileManager();
static FileManager* _fileManager;
std::vector<File> _files;
};
ファイルは私が作成したオブジェクトであり、ファイル IO を処理するための単純なインターフェイスにすぎません。過去にユーザー定義オブジェクトのベクトルを実行したことがありますが、このエラーが発生するのは初めてです。
File オブジェクトのコードは次のとおりです。
#pragma once
//C++ Header
#include <fstream>
#include <vector>
#include <string>
//C Header
//local header
class File
{
public:
File();
File( std::string path );
~File();
std::string ReadTitle();
void ReadContent();
std::vector<std::string> GetContent();
private:
std::ifstream _input;
std::ofstream _output;
char _IO;
std::string _path;
std::vector<std::string> _content;
};
ファイル.cpp
#include "file.h"
File::File()
: _path( "data/default.ndb" )
{
}
File::File( std::string path )
: _path( path )
{
}
File::~File()
{
}
void File::ReadContent()
{
}
std::string File::ReadTitle()
{
_input.open( _path.c_str() );
std::string title = "";
while( !_input.eof() )
{
std::string buffer;
getline( _input, buffer );
if( buffer.substr( 0, 5 ) == "title" )
{
title = buffer.substr( 6 ); // 5 + 1 = 6... since we want to skip the '=' in the ndb
}
}
_input.close();
return( title );
}
std::vector<std::string> File::GetContent()
{
return( _content );
}
Linuxでgccを使用しています。
解決策が何であるかについてのヒントやヒントをいただければ幸いです。
長い投稿で申し訳ありません。
ありがとう