Say we have an abstract base class IBase with pure virtual methods (an interface).
Then we derive CFoo, CFoo2 from the base class.
And we have a function that knows how to work with IBase.
Foo(IBase *input); The usual scenario in these cases is like this:
IBase *ptr = static_cast<IBase*>(new CFoo("abc")); Foo(ptr); delete ptr; But pointer management is better to be avoided, so is there a way to use references in such scenario?
CFoo inst("abc"); Foo(inst); where Foo is:
Foo(IBase &input);
IBase& b = CFoo();