c++ - Calling overloaded operator function from struct pointer -
i have following struct in c++
struct jam { void operator()() { cout << "test"; } }; and able call overloaded function so:
jam j; j(); but wondering proper way call function pointer same struct. example if have:
jam *j = new jam; j->(); i receive errors telling me needs function name. possible? thanks!
the easiest , clearest way dereference pointer:
(*j)(); alternatively, can use -> syntax function's name (which operator()):
j->operator()();
Comments
Post a Comment