I thought this would be easy, but it's not working the way I expected. What is the correct syntax here?
TemplateClass.h
template <typename T> 
class TemplateClass
{
  T & operator[](size_t n);
TemplateClass.cpp
#include "TemplateClass.h"
template <typename T>
T & TemplateClass::operator[](size_t n)
{
  // member declaration not found
}
                You need to provide the whole class name – including template arguments:
template <typename T>
T & TemplateClass<T>::operator[](size_t n)
{
  // ...
}
(Also note that the scope resolution operator is ::, not :.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With