PDA

View Full Version : copy constructors



04-09-2002, 09:40 AM
ive been told i need to write a copy constructor for the following bit of common code. the problem is i still dont know how to do it despite looking at a few tutorials. the reason i need it is im texture mapping many objects with different textures( 1 texture for each) and using a normal constructor i.e. COGLTexture picName; and setting picName to a texture image for each object will not work. any help would be great. thanks

#include <GL\glaux.h>

class COGLTexture
{
public:
_AUX_RGBImageRec *Image;
unsigned int GetID();
void LoadFromFile(char *filename);
void SetActive();
int GetWidth();
int GetHeight();
private:
int Width, Height;
unsigned int ID;
};

gumby
04-09-2002, 11:27 AM
Copy constructor is a constructor that takes
a const reference to an object of that type as an argument.

Nothing
04-09-2002, 11:53 AM
... and copies the >>complete<< content.

This includes memory allocation and memcpy.

As always www.google.com (http://www.google.com) is your friend.