atm I'm trying to find the best solution for creating objects(classes) with common properties but differ in one specific function. The reason I dont use a simple sub-class is, that I have about 50 "different" objects and I do not want to create a class for each of them.
Here is my attempt to do so:
class module{
public:
//..constructor and stuff
void (*work)();
}
int main(){
module A = new module();
A->work = [](mainclass* m_class) -> void {/*do smth specific */});
//... continue with B,C,...
}
I wonder if this is the most elegant (or most horrible) way to do this, or if there is a better concept for that kind of task.