R
Rene Ivon Shamberger
namespace jme {
template <class T> class Data {
private:
T data;
int id;
public:
Data();
Data(T, const int);
virtual ~Data();
Data(const Data& other);
Data& operator=(const Data& other);
const int getId();
const T& getData() {
return data;
}
};
template <class T>
jme:ata<T>:ata() {}
template <class T>
jme:ata<T>:ata(T _data, const int _id) {
this->data = _data;
this->id = _id;
}
template <class T>
jme:ata<T>::~Data() {}
template <class T>
jme:ata<T>:ata(const Data& other) {
//copy ctor
}
template <class T>
jme:ata<T>&
jme:ata<T>:perator=(const Data& rhs) {
//if (this == &rhs) return *this; // handle self assignment
//assignment operator
this->T = rhs.T;
//this->id = rhs.id;
return *this;
}
template <class T>
const int jme:ata<T>::getId() {
return id;
}
---
int main(){
jme:ata d;
std::cout << "Hello world!" << std::endl;
return 0;
}
The above program gives me this error message:
-------------- Build: Debug in data ---------------
Linking console executable: bin\Debug\list.exe
obj\Debug\main.o: In function `main':
C:/.../main.cpp:8: undefined reference to `jme:ata<std::string>:ata()'
C:/.../main.cpp:10: undefined reference to `jme:ata<std::string>::~Data()'
C:/.../main.cpp:10: undefined reference to `jme:ata<std::string>::~Data()'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
3 errors, 0 warnings
What am I doing wrong?
template <class T> class Data {
private:
T data;
int id;
public:
Data();
Data(T, const int);
virtual ~Data();
Data(const Data& other);
Data& operator=(const Data& other);
const int getId();
const T& getData() {
return data;
}
};
template <class T>
jme:ata<T>:ata() {}
template <class T>
jme:ata<T>:ata(T _data, const int _id) {
this->data = _data;
this->id = _id;
}
template <class T>
jme:ata<T>::~Data() {}
template <class T>
jme:ata<T>:ata(const Data& other) {
//copy ctor
}
template <class T>
jme:ata<T>&
jme:ata<T>:perator=(const Data& rhs) {
//if (this == &rhs) return *this; // handle self assignment
//assignment operator
this->T = rhs.T;
//this->id = rhs.id;
return *this;
}
template <class T>
const int jme:ata<T>::getId() {
return id;
}
---
int main(){
jme:ata d;
std::cout << "Hello world!" << std::endl;
return 0;
}
The above program gives me this error message:
-------------- Build: Debug in data ---------------
Linking console executable: bin\Debug\list.exe
obj\Debug\main.o: In function `main':
C:/.../main.cpp:8: undefined reference to `jme:ata<std::string>:ata()'
C:/.../main.cpp:10: undefined reference to `jme:ata<std::string>::~Data()'
C:/.../main.cpp:10: undefined reference to `jme:ata<std::string>::~Data()'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
3 errors, 0 warnings
What am I doing wrong?