I'm trying to learn template classes but am having some trouble. I keep getting "unresolved external" errors but finally narrowed it down to 1 error.
Minmax<T> Minimum unable to match function definition to an existing declaration
which would mean to me that it's unable to head my function header in MinMax.h but I can't tell why.
I know there is something wrong with my syntax but can't figure out what.
MinMax.h
1 2 3 4 5 6 7 8 9 10 11 12 13
#pragma once
template<class T>
class MinMax
{
private:
T value1;
T value2;
public:
//MinMax();
T Minimum(T, T);
T Maximum(T, T);
};
So put the member function definitions in MinMax.h, either below the class template or inside it (as inline member functions).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
template <class T>
class Example
{
public:
int func1(double);
int func2(char c)
{
// ...
}
};
template <class T>
int Example<T>::func1(double d)
{
// ...
}