Currently I have a class which contains another and provides a wrapper for some of its methods and provides others intact:
class bar {
public:
int calculate1(int a, int b) {
return f.calculate1(a, b);
}
int calculate2(int a, int b) {
a ++;
b ++;
return f.calculate2(a, b);
}
private:
foo f
}
Where foo
is a class containing 2 methods calculate1
and calculate2
, both taking 2 int
s and returning an int
.
Is there a better way to achieve this with inheritance? It would be nice to be able to get rid of this:
int calculate1(int a, int b) {
return f.calculate1(a, b);
}
But this would need to call the very function it is overloading, and I'm not sure how to do that:
int calculate2(int a, int b) {
a ++;
b ++;
return f.calculate2(a, b);
}
Is it even possible or advisable? Is there another method to be used in this situation?
apologies if some of my code is a bit dodgy, as you can tell I'm a bit new to C++, but I hope I got the message across.