2013-02-22 54 views
1

我是C++的新手,並且對此進行了深入研究,似乎無法弄清楚如何編譯這些內容,但不知道爲什麼。它適用於Visual C++,但不適用於Xcode。錯誤似乎在輸入流上。有什麼建議麼?無法在Xcode中使用ifstream

錯誤讀取 - 「未定義模板隱式實例化‘的std :: _ basic_ifstream>’

#include <iostream> 
#include <iostream> 
#include <string> 
using namespace std; 

int main() 
{ 
    cout << "The file is providing the data."; 
    ifstream myFile("/Users/me/Desktop/somewords.txt"); // * error 

    int i; 
    string s; 
    double d; 
    myFile >> i >> s >> d; 
    cout << "here is your data " << endl; 
    cout << i << endl << s << endl << d << endl; 


    return 0; 
} 

回答

6

你忘了#include <fstream>,實際上定義了你的所有ifstream善良的頭文件,包括你<iostream>兩次(或。至少嘗試),或許其中的一個的意思是<fstream>

+0

像這樣殺了你。謝謝你,它的一切工作的偉大了。願我的運氣在現場Wow..little東西:)哈哈 – SprayKid982 2013-02-22 12:38:08