【发布时间】:2012-02-07 05:39:06
【问题描述】:
I'm getting an "unresolved external symbol "public:__thiscall hijo<int>::hijo<int>(void)" referenced in function_main
我开始了一个新项目,因为我在另一个更大的项目中遇到了同样的错误。 当我尝试使用 new 关键字分配空间时发生错误。 如果这个错误是愚蠢的,请原谅我,因为我在过去几个月没有编程任何东西。
/********************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;
}
【问题讨论】:
标签: c++ templates inheritance linker-errors