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.
+4
A:
Pontus Gagge
2009-04-14 13:09:16
+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
2009-04-14 13:10:35
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
2009-04-14 13:12:26
Ok, infinite recursion might be kind of a problem. ;-)
Konrad Rudolph
2009-04-14 13:16:48
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
2009-04-14 13:13:59