在C ++中的堆栈上创建模板化类的实例

时间:2020-01-26 14:56:09

标签: c++ class templates

我想在堆栈上创建模板化类的实例。例如:

在我的Point.h文件中:

template <class T>
class Point
{
public:
    Point();
    ~Point();
};

在我的Point.cpp文件中:

template <class T>
Point<T>::Point() {
}

template <class T>
Point<T>::~Point() {
}

现在我要这样做:

#include "Point.h"

int main(void)
{

    Point<int> first = Point<int>();


    return 0;
}

但是出现以下错误:

ld:架构x86_64找不到符号

所以我想我的问题是,我该如何进行这项工作?我可以不用模板类就可以工作。

0 个答案:

没有答案