This question already has an answer here:
- Why can templates only be implemented in the header file? 14 answers
I'm getting an "unresolved external symbol "public:__thiscall hijo<int>::hijo<int>(void)" referenced in function_main
I started a new project cause I was having this same error on another larger project. The error occur when I try to allocate space using the new keyword. If this error is silly please forgive me cause I haven't programmed anything in the last months.
/********************file hijo.h******************/
#pragma once
#ifndef hijo_h
#define hijo_h
template <class A>
class hijo
{
public:
hijo(void);
~hijo(void);
};
#endif
/********************file hijo.cpp***************/
#include "hijo.h"
#include <iostream>
using namespace std;
template <class A>
hijo<A>::hijo(void)
{
}
template <class A>
hijo<A>::~hijo(void)
{
}
/*********************at main() function ***************/
#include <iostream>
#include "hijo.h"
int main(){
hijo<int> *h = new hijo<int>; <---- PROBLEM AT THIS LINE
system("pause");
return 0;
}