Hello, I know it is possible, but I cant remember how to do it. I need to make a function that can take any object as a parameter. I think I use the CObject class but I could be wrong. Can anyone point me in the right direction.
I think it's too abstract question. can take any object as a parameter? Object of what hierarchy? No any super object (Adam or Eve in the Object Universe. It's Java (wrong designed Object superclass, but we are on (MS) C++ forum (don't you?)...
The only way to accept a pointer to any object is:
I want to take an object and an enumerated type as perameters. Based on the enumerated type, I want to cast the object to a particular type. Is it possible to do this with a CObject?
In general you can't cast an object of one class to another class (with or without CObject). So explain, please, your true problem.
In MFC environment you derive the class from the CObject if you need CObject functionality (serialization, for example). Then you may pass CObject pointer or reference to the derived class object and use it in a function as a polymorphic (CObject type) object via virtual functions. You don't cast it, you use it as a CObject object.
What else?
Can you present minimal pseudocode snippet with desired ops on your generic argument?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.