我有構造做了一些工作,所以我調用構造函數裏面一個成員函數:當類的構造函數調用其成員函數時,會發生刪除函數錯誤的使用?
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
class Token{
public:
Token() {}
Token(const string &targetfile);
void GetToken();
ifstream in;
};
Token::Token(const string &targetfile)
{
in.open(targetfile);
GetToken();
}
void Token::GetToken()
{
in.close();
}
int main(int argc,char *argv[])
{
Token first = Token(string(argv[1]));
return 0;
}
我有錯誤是這樣的:
使用刪除功能「令牌::令牌(令牌& &)」 一張字條:‘令牌::標誌(標誌& &)’被隱式刪除,因爲默認定義將形成不良的
這編譯與g ++:https://ideone.com/M4BAgN – jpo38
我得到錯誤使用:g ++ -std = C++ 11 debug.cpp -o調試 – programforjoy
你嘗試了不同的選擇嗎? ideone.com使用C++ 14 – jpo38