Answer the question
In order to leave comments, you need to log in
Why is it impossible to separate the methods of the template class?
MinGW compiler, codeblocks
Here is an example:
File Sample.h
#pragma once
template<typename T> class Example
{
public:
int Get();
};
#include"Example.h"
template<typename T> int Example<T>::Get() { return 4; }
#include<iostream>
int main()
{
Example<int> example;
std::cout<<example.Get();
}
undefined reference to 'Examle::Get()'
#pragma once
template<typename T> class Example
{
public:
int Get();
};
template<typename T> int Example<T>::Get() { return 4; }
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question