Okay, I will try to explain a little, then if you have any questions just post back. Take the following code for example.
Code:
class CPoint
{
private:
int m_x;
int m_y;
};
There is a simple class for a point, not terribly interesting. Now I didn't explicity declare my destructor and contructor because there are default ones supplied for you if you do not specify one. I could specify mine own like this.
Code:
class CPoint
{
private:
int m_x;
int m_y;
public:
CPoint(); // Constructor
~CPoint(); // Destructor
};
The constructor is called when the class variable is created or instantiated. The destructor is called either when the variable goes out of scope, or you call delete on a pointer variable.
If i wanted to though, I could make my own special constructor. Take this code.
Code:
// CPoint.h file...
class CPoint
{
private:
int m_x;
int m_y;
public:
CPoint( int x, int y ); // Constructor
~CPoint(); // Destructor
};
// CPoint.cpp file (implementation of class)
#include "CPoint.h"
CPoint::CPoint( int x, int y )
{
m_x = x;
m_y = y;
}
CPoint::~CPoint( )
{
}
I don't know if that really clears anything up but perhaps. If you have more specific questions just ask.