文字列であるメンバーのコンストラクターを使用するにはどうすればよいですか?ここに例があります(私が理解しているのは間違っています)
class Filestring {
public:
string sFile;
Filestring(const string &path)
{
ifstream filestream(path.c_str());
// How can I use the constructor for the member sFile??
// I know this is wrong, but this illustrates what I want to do.
string sFile((istreambuf_iterator<char>(filestream)), istreambuf_iterator<char>());
}
};
したがって、基本的には、文字列のコピーを行わずにメンバーsFileのコンストラクターを使用できるようにしたいのです。割り当てを通じてこれを達成する方法はありますか?