Can I put a function inside a structure?

Maybe I'm using built-in functions ... Is there a way to archive it without using function pointers?

Thanks in advance.

+3
source share
5 answers

Not in C. You can in C ++. A structure is just a class, with all members being publicly accessible by default in that language.

+5
source

No, the structure only supports a function pointer.

+4
source

C. ++.

+3

, , ( ).

+1

, , a, C, : , .

however, as pcent pointed out, a function pointer is a data type and can be stored in a structure.

+1
source

Source: https://habr.com/ru/post/1749670/


All Articles