我曾尝试使用下面的代码片断:ifstream的在C++中不接受可变
int main()
{
string location_file ("test.txt");
string data;
ifstream file (location_file);
getline (file, data);
file.close();
cout << data;
return 0;
}
但它不会工作。现在,如果我使用“ifstream文件(”test.txt“)”它会。为什么?最后它不是一回事吗?
@pmr:关于你的编辑:包含初始化符*的声明是一个定义(除少数例外,但这不是其中之一) – celtschk 2012-04-01 13:31:18
Upvoted for the explanation。Did not know that。谢谢。 – MKII 2012-04-01 13:52:06
@celtschk好的。这是否意味着定义在引用函数/ cl时有所不同驴的定义和何时用于名称? – pmr 2012-04-01 13:55:57