I know that you can get context for a static method like this:
< Code> typedef zero (* indicator) (); Indicator P = & amp; MyClass :: MyMethod;
But is there a way to get the context of the class?
Edit: I want to store a variable name in a variable, so I can instantiate different types of objects based on the current value of the buffer or a variable in a list. I can then list the objects (using polymorphism). No, "class" is not an object that is present at runtime in C ++ -
This is a compiled time concept only so that you can not get the reference or pointer "one class object" per second, only examples, functions (including static ones), and so on - things that do runtime Exist.
With RTTI, you can get equal effect to some extent, however - the keyword refers to you std :: type_info
(you have #include & lt; typeinfo & Gt; / code> to enable this) to enable this functionality on the runtime "stands for" type of question (for Microsoft Visual C ++, code) / GR
You may also need special compiler switches.
It is good for you that it is absolutely fine that what is it that you are trying to fulfill? Take care to make it clear?
Comments
Post a Comment