This question already has an answer here:
- Get the list of methods of a class 7 answers
In Java
import java.lang.reflect.Method;
Method[] getClassMethods(Class class) {
Method[] methods = class.getDeclaredMethods();
return methods;
}
In PHP
array get_class_methods(mixed $class);
To do something similar in C++
template <class Class, typename Method>
std::vector<Method> getClassMethods(Class c) {
std::vector<Method> methods;
// populate vector with methods of the class
return methods;
}
and use it as
for (auto f : Methods)
f(...);
Question: Is it possible to get a list of declared methods / functions in either of a
- class
- namespace
- header file
in C++ ?
EDIT This question is limited to methods of a class only.
Aucun commentaire:
Enregistrer un commentaire