Probleme mit Templates??
-
Hallo, ich habe folgende Testumgebung. Bin noch bltiger Anfänger und schlage mich mit Templates herum...
Mainmethode:
#include <iostream> #include "profi.h" using namespace std; int main() { Profi <int>t; t.a = 1; t.b = 4; cout << t.addP() << endl; return 0; }
Testklasse:
template <class T> class Profi { public: int a; int b; int addP(void); };
und
#include <iostream> #include "profi.h" using namespace std; template <class T> int Profi<T>::addP() { return (a + b); }
Beim Kompilieren kommt immer folgender Fehler, ich kann damit nicht wirklich etwas anfangen und bekomm ihn nicht raus. Weiss da evtl. jmd. weiter und kann mir helfen??
Kompilierung läuft...
test.cpp
Linker-Vorgang läuft...
test.obj : error LNK2001: Nichtaufgeloestes externes Symbol "public: int __thiscall Profi<int>::addP(void)" (?addP@?$Profi@H@@QAEHXZ)
Debug/test_heap.exe : fatal error LNK1120: 1 unaufgeloeste externe Verweise
Fehler beim Ausführen von link.exe.
*Vielen Dank bereits im Voraus!!
Gruss
Chris
-