I am trying to create polymorphic classes but with no luck.
I have .h files and .cpp files.
I am declaring my classes in .h files and defining each function in .cpp files. I have a class called Sprite and a class called Animation that inherits from Sprite.
An Animation object is created inside an Entity object.
Then of course I specify what type of sprite it is in Entity.cpp:
void Entity::initialise( Graphics* pGraphics, //Graphics address
const char* pFile, //File name address
int frameWidth, //frame with
int frameHeight, //frame height
int columns, //columns
int frames, //frames
int startFrame, //startFrame
int currentFrame, //currentFrame
int endFrame ) //endFrame
look = new Animation();
Unfortunately that doesn't compile because it says that my initialise function contains too many arguments. Because Sprite::initialise takes only two arguments, I think the compiler is expecting that one initialise function even though my sprite::initialise function is declared as virtual in sprite.h
What is going wrong?
Should I also define the functions as virtual?
If so, where exactly do we put "virtual" in the definition?
Should I declare Animation::initialise as virtual as well?
Thanks a lot for the help,