tags:

views:

306

answers:

3
+4  A: 

What you can do is shadow, but not override. That is: you can define a derived class Y with its own typedefs for TokenType, but that will only come into play if somebody references Y::TokenType directly or via an object statically typed as Y. Any code that references X::TokenType statically will do so even for objects of type Y.

Pontus Gagge
+4  A: 

Typedefs are resolved at compile time – making them overridable would be meaningless, since overriding is a feature of runtime polymorphism.

Simply redeclaring the typedef will work – though I'm not sure why you think templates would be a bad idea here – recursive templates are actually feasible.

Konrad Rudolph
Sorry, missed the word infinite from my recursive template sentence. This entire class is a work around for an infinitely recursive template problem, so adding this type as a template argument is impossible. Shame really, templates would be the best way to handle this.
Ed Woodcock
Ok, infinite recursion might be kind of a problem. ;-)
Konrad Rudolph
A: 

Short answer: No, you cannot override typedefs.

Long answer: A typedef is basically an alias or synonym for another type. They don't define new data types. They simply provide a way to give a type a new name.

Aaron Saarela