Because of the way that type aliases work, it looks to your compiler like you're trying to define MyClass::String
inside of itself. It gets all confused.
[C++11: 7.1.3/6]:
In a given scope, a typedef
specifier shall not be used to redefine the name of any type declared in that scope to refer to a different type. [..]
Here's a complete example:
typedef int alias_t;
class T
{
typedef alias_t alias_t;
};
Output:
test.cpp:4: error: declaration of 'typedef alias_t T::alias_t'
test.cpp:1: error: changes meaning of 'alias_t' from 'typedef int alias_t'
I can fix this example by adding the ::
prefix to the existing type:
typedef int alias_t;
class T
{
typedef ::alias_t alias_t;
};
In your code, that translates to the following:
class MyClass
{
typedef ::String String;
};