OK, let's say I have an abstract base class BaseClass and a derived class Derived:
Code:
class BaseClass
{
public:
BaseClass();
virtual ~BaseClass();
virtual void DoSomething() const = 0;
};
Is it necessary to redeclare each virtual function in the derived class, or will just the definition suffice? i.e. will the following work?
Code:
class Derived: public BaseClass
{
public:
Derived();
virtual ~Derived();
};
void Derived::DoSomething()
{
DoStuffADerivedWouldDo();
DoSomeOtherStuff();
}
If I do have to redeclare it, will it make any difference whether the redeclaration is virtual or not? (i.e. is there any reason not to make it virtual, or will it end up virtual even if I don't declare it as such?)
Also, if I do something like this:
Code:
BaseClass *abaseclass=new Derived;
Do the constructors from both classes get called, or do I need to do everything in Derived's constructor that I had to do in BaseClass's?
Thanks in advance.