Link to home
Start Free TrialLog in
Avatar of gamesmeister
gamesmeisterFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Retrieving a Constant from a polymorphic object

Hi all,

I have a number of classes, each inheriting from an interface, and each with a matching const (i.e. the name of the const is the same, the value is different).

If I'm viewing an instance of one of these classes polymorphically via the interface, is there an easy way to access it's constant value? I could obviously add methods to each base class to return the const, but I wondered if there was any other, perhaps better, way of doing it?

Thanks
Gerry
ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gamesmeister

ASKER

Yeah, I figured that would be the best way, just wondered if I'd missed something.

Off to update 30+ subclasses...

Thanks Alex