Problem with constructor!
Ok, I''ve got a standard class:
class CSurface
{
public:
// Globals
LPDIRECTDRAWSURFACE7 surface;
// Functions
CSurface();
~CSurface();
void LoadFromBMP(char* filename, LPDIRECTDRAW7 lpdd); // Load from BMP image
private:
}
and:
#include "csurface.h"
CSurface::CSurface()
{
}
CSurface::~CSurface()
{
if(surface)
{
surface->Release();
surface = NULL;
}
}
But I get the error:
error C2533: ''CSurface::CSurface'' : constructors not allowed a return type
If you just copied the code over try putting a semi-colon after the class declaration
Else
Else
joeG
Hi there!
I know you already got an answer to your question but I would just like to make a small comment on your code here:
You should always clear the pointers at initialization, in this case you should add surface = 0; to your CSurface constructor.
You will probably never notice any difference since you allocate memory for it in LoadFromBMP(), or so I guess, but if you are not careful you might try to delete memory that is not allocated.
I know you already got an answer to your question but I would just like to make a small comment on your code here:
You should always clear the pointers at initialization, in this case you should add surface = 0; to your CSurface constructor.
You will probably never notice any difference since you allocate memory for it in LoadFromBMP(), or so I guess, but if you are not careful you might try to delete memory that is not allocated.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement