Define functions in structs

c

Solution

No, as functions are not data. But you can define function pointers inside a struct.

struct foo {
    int a;
    void (*workwithit)(struct foo *);
}

Problem

Can we define functions in structs in C programming language?

Original source

Related problems