Hello!
This is my first time making classes and I have some problems compiling and running my program.
My program consists of 3 parts:
- main.cc
- calculation.cc
- calculation.h
in the Calculation.h:
#ifndef _CALCULATION_H_
#define _CALCULATION_H_
#include <string>
using namespace std;
class Calculation {
public:
Calculation ();
virtual ~Calculation();
void getSize();
protected:
int a, b;
};
#endif
in Calculation.cc:
#include <iostream>
#include <string>
#include <vector>
#include "Calculation.h"
Calculation::Calculation() {a=0; b=0;}
Calculation::~Calculation() {}
void getSize() {
cout << "hi" << endl;
}
in the main.cc:
#include <iostream>
#include <string>
#include "Calculation.h"
using namespace std;
int main( int argc, char *argv[] ) {
Calculation calc;
calc.getSize();
}
I'm compiling and linking them this way:
g++ -c Calculation.cc
g++ -c main.cc
g++ Calculation.o main.o -o test
however, when executing "g++ Calculation.o main.o -o test", this error occurs:
Undefined first referenced
symbol in file
Calculation::getSize(void) /var/tmp/ccebkQ3K.o
ld: fatal: Symbol referencing errors. No output written to test
collect2: ld returned 1 exit status
Does anyone have any idea what this error is trying to say?
I'm so confused~~ Can anyone point me in the right direction?
Thanks a lot!!



LinkBack URL
About LinkBacks





