I need to write a class in C++ that would represent an abstraction of a calculation. That class will have a function that will run an actual calculation.
class Calculation {
Calculation() {}
~Calculation() {}
Calculate(); //member function that runs a calculation
};
I need that class to be able to represent different sorts of calculations and run different calculation as the result of calling Calculation::Calculate(). What are some good approaches to do this in C++? I could do that just passing some flags into constructor, but this doesn’t seem to be a good solution.
You can make
Calculatevirtual and create child classes that implement the varying behavior you need.