class function assigned to zero?

Oct 5, 2011 at 2:12pm
What does it means when a class function equals zero:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
template <class xtyp_state> 
class CStates
{

	CStates(void);

public:
	
	~CStates(void);
	//This is called when the state is entered
    virtual void Enter(xtyp_state*)=0;
	
	//This is called regularly once the state is entred
	virtual void Execute(xtyp_state*)=0;
	
	//This is called when the state is exited
	virtual void Exit(xtyp_state*)=0;

};

#endif 
Oct 5, 2011 at 2:21pm
Those are pure virtual functions, and what it means is that any classes derived from CStates MUST overload Enter, Execute and Exit. It also makes CStates an abstract class, so you cannot create an instance of the class, only classes derived from it which overload the pure virtual functions. Basically abstract classes are designed specifically to be base classes and nothing more.
Last edited on Oct 5, 2011 at 2:22pm
Oct 5, 2011 at 3:18pm
the "=0" means this function is a pure virtual function,
any class that includes at least one pure virtual function ,it becomes a abstract class ,which can not instantiated ,just can be the base class .
:)
Topic archived. No new replies allowed.