This should be easy to fix but im in the dark.
LineCounter.h
Code:
#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
LineCounter.cpp
Code:
#include "LineCounter.h"
int CommentCount = 0;
int LineCount = 0;
void LineCounter::countLines(){
}
int LineCounter::getCommentCount(){ return CommentCount;}
int LineCounter::getLineCount(){ return LineCount;}
Main.cpp
Code:
#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
}
}
Compile command
Code:
c++ LineCounter.cpp Main.cpp -o Program.exe
Error:
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'