I have a class and a nested class:
template<class T>
class foo
{
public:
struct small_foo
{
small_foo& operator=(const small_foo& other);
};
};
and a soruce file that looks like that:
#include "foo.h"
template<class T>
foo<T>::small_foo& foo<T>::small_foo::operator=(const small_foo& other)
{
//Some code
return *this;
}
While im compiling (static library) I'm getting 3 errors and a warning:
warning C4346: :small_foo": name is not a type
error C2061: syntax error : identifier 'small_foo'
error C2143: syntax error : missing ';' before '{'
error C2447: '{' : missing function header (old-style formal list?)
EDIT:
The problem was that the compiler couldn't tell what foo<T>::small_foo&
in foo<T>::small_foo& foo<T>::small_foo::operator=(const small_foo& other)
was. The solution is to add typename keyword in front of it so it looks like that:
template<class T>
typename foo<T>::small_foo& foo<T>::small_foo::operator=(const small_foo& other)
{
//Some code
return *this;
}