jeudi 2 juillet 2015

Get List of Declared Functions / Methods [duplicate]

This question already has an answer here:

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

  1. class
  2. namespace
  3. header file

in C++ ?

EDIT This question is limited to methods of a class only.

Aucun commentaire:

Enregistrer un commentaire