Is there a way to create a list (e.g. an array) of pointers to each method of a C++ class?
Something like Type.GetMethods() in the .NET framework, but using only standard C++.
Is there a way to create a list (e.g. an array) of pointers to each method of a C++ class?
Something like Type.GetMethods() in the .NET framework, but using only standard C++.
Make a copy of the .h file and hack away with it in an editor.
No, there's no way to do it automatically.
No this is not possible in a general way. C++ does not have the same metadata infrastructure that .Net posses.
Could you provide us with a scenario where you want to use this information? There may be a better approach you can use with C++
There is no meta classes in C++ only objects and classes, hence no reflection could not be involved, so the answer is no.
You can get the type information using typeid but not the method information.
There is no way.
In fact, even at the object code level, a static class member function cannot be distinguished from a stand-alone function, nor a class instance function from a stand-alone function passing a pointer to an object.
If you know your compilers name-mangling scheme, and had access to the pre-linked object code, you might be able to decode it, but that's a lot of work for iffy results.
If you really want to do this, chapter 8 of Advanced C++ Programming Styles and Idioms by James Coplien (probably long-since out of print, but I hear Neil would be willing to sell his copy cheaply) covers programming with "exemplars" in C++. Make not mistake, the capability doesn't come for free, but it can/does provide metaclass-like capabilities in C++.
Offhand, I don't remember his building the particular capability you're looking for into one of his classes, but it's been a long time since I read that book carefully at all either. It's always possible that it couldn't be done at all, but I think it would work, if you can live with the other limitations of what he discloses.