This should be easy to fix but im in the dark.
LineCounter.h
LineCounter.cppCode:#ifndef LINE_COUNTER_H #define LINE_COUNTER_H class LineCounter{ private: char pC; char pNC; char C; char NC; static int CommentCount; static int LineCount; bool ReachedEndOFLine; public: void countLines(); int getCommentCount(); int getLineCount(); }; #endif
Main.cppCode:#include "LineCounter.h" int CommentCount = 0; int LineCount = 0; void LineCounter::countLines(){ } int LineCounter::getCommentCount(){ return CommentCount;} int LineCounter::getLineCount(){ return LineCount;}
Compile commandCode:#include <iostream> #include <fstream> // file I/O #include "LineCounter.h" using namespace std; int main(int argc, char *arg[]){ if (argc < 1){ cout << "Usage is 'sloc files[]'"; return 0; }else{ ifstream SourceFile(arg[1], ios::in); // declare and open } }
Error:Code:c++ LineCounter.cpp Main.cpp -o Program.exe
Code:/tmp/cc0kkubh.o: In function `LineCounter::getCommentCount()': LineCounter.cpp:(.text+0xa): undefined reference to `LineCounter::CommentCount' /tmp/cc0kkubh.o: In function `LineCounter::getLineCount()': LineCounter.cpp:(.text+0x14): undefined reference to `LineCounter::LineCount'



LinkBack URL
About LinkBacks


