I've noticed lines of code like this in the book I'm reading:
namespace sf
{
class RenderWindow;
}
class StateStack;
class Player;
class State
{
// Code for the class
};
What do the lines with just the class, classname, and semicolon mean?
Answer
These are forward declarations. They let the following code know that there is are classes with the names RenderWindow
, StateStack
, and Player
. This satisfies the compiler when it sees these names used. Later the linker will find the definition of the classes.
No comments:
Post a Comment