class CDataStorageImpl : public IDataStorage
{
virtual bool storedata();
}
but like I said this is the implemented class, so there exists the function
bool CDataStorageImpl::storedata()
{
/* some junk */
return true;
}
I don't understand why the implemented class would use the virtual keyword for the function definition, I think it shouldn't be virtual because it is implemented. Can someone explain why this is the case?
Thanks
Patrick
Once a function is declared virtual in a base class it is always virtual in all descendants.
Therefore, although it can be declared virtual, it is not necessary.
Having said that, I believe you are confusing virtual functions with pure virtual functions. The keyword virtual is not used to indicate that a function is not implement; = 0 is used for that: eg,
virtual void foo() = 0; // = 0 means pure virtual i.e, unimplemented in this class.
virtual is used to tell the compiler to allocate a vtable entry for the function and make all calls to the function be resolved at runtime.