Yahoo Interview Question
Software Engineer / DevelopersIf we are talking about functions (or I prefer methods) only then it can be easily done by putting all needed methods to another class internal to out target class, declare a _static_ field of type of that internal class and access to methods thru that object.
I am a bit rusty with C++ so I am not sure if it is possible to use unnamed structure. If not then it appears to be possible to implement the outer class as a proxy of the inner class, i.e. make them implement the same interface but call inner class instance methods from the outer class.
Lastly I really doubt hacks of such kind may have any practical purpose.
having a global object of this class, then use the object to invoke those functions. Similiar to the static functions.
- adon July 21, 2007