Answer the question
In order to leave comments, you need to log in
I created a class in a pure C++ project, but when I try to allocate memory for it in main, I catch an unresolved external symbol. Why?
header file
#pragma once
template <typename T>
class Tree
{
public:
Tree();
~Tree();
};
#include "pch.h"
#include "Tree.h"
template <typename T>
Tree<T>::Tree()
{
}
template <typename T>
Tree<T>::~Tree()
{
}
int main()
{
auto tvar = new Tree<int>;
std::cout << "Hello World!\n";
}
Answer the question
In order to leave comments, you need to log in
cpp filetemplate <typename T> Tree<T>::Tree() { }
Tree<int>
in some other file? Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question