'Inherited Templates - C++ [duplicate]
I have a template base class and an inherited class. There is a function inside the baseclass which can accept difference types, I expected that I would call this from inside the inherited class with 'BaseClass::Add();' but I instead receive the error "expected primary-expression before ‘>’ token".
How do I call BaseClass::Add with U?
template <typename T>
class BaseClass
{
public:
template <typename U>
void Add() {
// Do stuff
}
};
template <typename T>
class InheritedClass : public BaseClass<T>
{
public:
template <typename U>
void Add() {
BaseClass<T>::Add<U>(); // Error here
}
};
Thanks in advance
Solution 1:[1]
Use this syntax
BaseClass<T>::template Add<U>()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | francesco |
