This is a minimal example of my problem. I have 2 classes, one is abstract, the other one is derived.
#include <iostream>
class A
{
public:
virtual void foo() = 0;
void bar() {
foo();
std::cout << "BAR" << std::endl;
}
};
class B : public A
{
public:
void foo() {
std::cout << "FOO" << std::endl;
}
};
int main()
{
B b;
b.bar();
}
The code compiles and gives the expected result: FOO\nBAR.
Now to the question: Because the foo-method of class B is completely independent (uses no variables or other methods of B or A), I want foo to become static. Basically I want to call foo with B::foo().
Declaring foo static doesn't work, since foo implements the virtual method from A. How do you handle such a case?