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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -