i have code:
Code:
//main.cpp
#include "src/shm_obj.h"
struct __DATA{
int index;
char *value[200];
};
typedef __DATA data;
int main(int argc,char **argv){
data *d=new data;
d->index=123;
strcpy((char*)d->value,"qwerty");
shm_obj<data>::create(d); //!!! undefined reference to 'shm_obj<__DATA>::create(__DATA*)'
return EXIT_SUCCESS;
}
Code:
//shm_obj.h
#ifndef SHM_OBJ_H_
#define SHM_OBJ_H_
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
template<typename T>
class shm_obj{
private:
T *obj;
static shm_obj<T> *__instance;
private:
shm_obj(T *__obj);
public:
static shm_obj<T> create(T*);
static T *get();
virtual ~shm_obj();
};
#endif /*SHM_OBJ_H_*/
Code:
//shm_obj.cpp
#include "shm_obj.h"
template<typename T>
shm_obj<T>::shm_obj(T *__obj){
this->obj=__obj;
}
template<typename T>
shm_obj<T> shm_obj<T>::create(T *__obj){
shm_obj<T>::__instance=new shm_obj<T>;
return shm_obj<T>::__instance;
}
template<typename T>
T *shm_obj<T>::get(){
return __instance->obj;
}
template<typename T>
shm_obj<T>::~shm_obj(){
}
where is error??
help me please...