variable 'std:ofstream' has initializer but incomplete type 錯誤

【1】問題描述

最近在寫工具的時候,代碼編譯出現 variable 'std:ofstream’ has initializer but incomplete type 或者是 variable 'std:ifstream’ has initializer but incomplete type


【2】原因

因爲沒有包含fstream這個頭文件。


【3】代碼詳解

#include<fstream>  
#include<iostream>  
#include<string>   

using namespace std;

int main() {
    fstream f("filename");
    f << 20;
    f.close();
}
上面的代碼,如果不包含fstream頭文件,就無法完成編譯。

搞定!


allenlinrui

2014/02/21


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章