Was ist hier falsch (C++ und Headerfiles und Makefile)
-
Hab hier nen kleines Testprogramm geschrieben:
the main.cpp:
#include <stdlib.h>
#include <iostream>
#include <stdio.h>
#include <string.h>#include "testme.h"
using namespace std;
int main() {
testme *test = new testme(5);
test->modify(3);
cout << test->getVar();
}
-----------------------------------
the testme.cpp:
class testme
{
private: int var;public:
testme() {
var = 0;
}
testme(int i) {
var = i;
}
void modify(int i) {
var = i;
}
int getVar() {
return var;
}
};------------------------------
the testme.h :
#ifndef testme_H
#define tesme_Hclass testme
{
private: int var;public:
testme();
testme(int i);
void modify(int i);
int getVar();
};#endif
------------------------------------------and the Makefile :
testfile : main.o testme.o
g++ main.o testme.o -o testfilemain.o : main.cpp testme.h
g++ -c main.cpp
testme.o : testme.cpp
g++ -c testme.cppclean : rm main.o testme.o
--------------------------------------------
aber es funktioniert nicht.. beim binden am ende kommt folgende Fehlermeldung:g++ main.o testme.o -o testfile
main.o(.text+0x2d): In functionmain': : undefined reference totestme::testme(int)'
main.o(.text+0x73): In functionmain': : undefined reference totestme::modify(int)'
main.o(.text+0x84): In functionmain': : undefined reference totestme::getVar()'
collect2: ld returned 1 exit status
make: *** [testfile] Error 1warum??
vielen danke schonmal

-
öhm warum denn gleich 2 mal ?