2012-01-25 11 views
24

Implicit instantiation of undefined template 'std::basic_ifstream<char,std::char_traits<char>>'मुझे यह ifstream त्रुटि क्यों मिल रही है?


#ifndef MAPPER_H 
#define MAPPER_H 
#include <iostream> 
#include <string> 
#include <vector> 
#include "KeyValue.h" 
#include "Parser.h" 

using namespace std; 
class Mapper 
{ 
public: 
    Mapper(ifstream& infile); 
    ~Mapper(void); 
    void loadTokens(); 
    void showTokens(); 
    void map(); 
    void printMap(); 
    void printMap(string map_fileName); 
private: 
    ifstream inFile; //<-- is where the error is happening 
    vector<string> tokens; 
    vector<KeyValue> map_output; 
    Parser* parser; 
}; 

#endif 

मैं भी std::ifstream डालने की कोशिश की है और यह अभी भी काम नहीं करता।

जब मैं #include <iostream> बजाय #include <fstream>, मैं fstream.tcc और basic_ios.tcc में इन त्रुटियों को मिलता है:

'operator=' is a private member of 'std::basic_streambuf<char>'

और चूंकि कि fstream पुस्तकालय का हिस्सा है, स्पष्ट रूप से कुछ मैं कर रहा हूँ गलत है ...

कोई भी मदद करने में सक्षम है?

+1

आपके पास '' '' 'ऑपरेटर =' वास्तविक त्रुटि है। आउटपुट विंडो में उस त्रुटि संदेश का शेष होना चाहिए, जिसमें लाइन नंबर भी शामिल है जहां आप 'मैपर' ऑब्जेक्ट की एक प्रति बनाते हैं। –

+0

आपको उस कोड को दिखाने की ज़रूरत है जो दूसरी त्रुटि का कारण बनती है। –

उत्तर

58

आप

#include <fstream> 

वंचित हो रहे हैं और आप शायद inFile जिसकी अनुमति नहीं है करने के लिए somthing आवंटित।

+0

किसी कारण से मेरा प्रश्न उस भाग को काटता है जहां मैंने पहले से ही fstream – OghmaOsiris

+0

आयात किया है, आप इसे संपादित कर सकते हैं। और यह एक न्यूनतम उदाहरण प्रदान करने में मदद करेगा कि अन्य संकलन करने का प्रयास कर सकते हैं। –

+2

मुझे लगता है कि 'ifstream' को '' में शामिल किया गया है जब तक कि मैंने अपने घुटने में तीर नहीं लिया। – acgtyrant