Hallo Leute,
ich habe obige Fehlermeldung bekommen, und ich weiß erhlich nicht wo mein Fehler liegt:
Die Datei IndexWord.h
Die Datei IndexWord.cpp
Die Fehlermeldung, die ich bekomme:
IndexWord.cpp: In function ‘std::string getWord()’:
IndexWord.cpp:24:10: error: ‘_word’ was not declared in this scope
IndexWord.cpp:25:1: warning: control reaches end of non-void function
Wo liegt mein Fehler?
ich habe obige Fehlermeldung bekommen, und ich weiß erhlich nicht wo mein Fehler liegt:
Die Datei IndexWord.h
Code:
#include <string> #include <vector> #include "./File.h" // when the indexing starts, this class saves every word for a filename // (saved in Filelist and could be get through the id) and counts the // number of appearances in the file class IndexWord { public: // increases the number of this word in a file void increase(); // Constructor, sets the word and id explicit IndexWord(std::string word, size_t id); // returns the word for which is made this index std::string getWord(); private: // id of the parsed file size_t _id; // the word for which the file is indexed std::string _word; // number of appearances in the file size_t _number; };
Code:
#include <string> #include "./IndexWord.h" IndexWord::IndexWord(std::string word, size_t id) { _word = word; _id = id; } // _____________________________________________________________________________ void IndexWord::increase() { _number++; } // _____________________________________________________________________________ std::string getWord() { return _word; }
IndexWord.cpp: In function ‘std::string getWord()’:
IndexWord.cpp:24:10: error: ‘_word’ was not declared in this scope
IndexWord.cpp:25:1: warning: control reaches end of non-void function
Wo liegt mein Fehler?
Comment