interface implementation with additional default arguments?
I have a question about implementing interface in C++:
Suppose there is an interface:
class A
{
virtual void f() = 0;
};
When implementing this, I wonder if there's a way to do something like:
class B : public A {
void f(int arg=0) {....} // does not compile..
};
I want to keep the iterface clean. When client code calls through public
interface A, arg is always set to 0 automatically. However when I call it
through B, I have the flexibility to call it with arg set to some
different value. Is it achievable?
Thanks!
No comments:
Post a Comment