3

In this question, the accepted answer uses the following syntax:

typedef std::map<std::string, Base*(*)()> map_type;

Can someone explain what the (*) means, I've never seen it before?

Community
  • 1
  • 1
stack user
  • 835
  • 1
  • 9
  • 28

1 Answers1

5

It is a function pointer that returns a Base pointer and takes no arguments, e.g.

struct Base {};

Base* myfun() {
    return 0;
}

int main() {
    std::map<std::string, Base*(*)()> mymap;
    mymap.insert(std::make_pair("hello", myfun));
}

Example

Marco A.
  • 43,032
  • 26
  • 132
  • 246