Newbie: different problem with references

M

Manuel

Hi...yet, another problem with references...sorry...

This is my singleton header:

-----------------------------------------
class MHwindow {
private:
static MHwindow MHw;

GLuint texture;

//Constructor is private, because this is a singleton
MHwindow(GLuint &);
MHwindow& operator=(MHwindow&); // Disallowed
MHwindow(const MHwindow&); // Disallowed

public:
static MHwindow& instance() { return MHw; }

void setTexture(GLuint);
GLuint getTextures();
};
----------------------------------------

This is my singleton cpp file:

----------------------------------------
MHwindow::MHwindow(GLuint & textur)
{
pngInfo texInfo;
textur = pngBind("pippo.png", PNG_NOMIPMAP, PNG_ALPHA, NULL, GL_CLAMP,
GL_NEAREST, GL_LINEAR);
}

void MHwindow::setTexture(GLuint i){texture = i;};
GLuint MHwindow::getTextures(){return texture;};

----------------------------------------

this is the usage I'm trying:
----------------------------------------
GLuint textureID;
MHwindow MHwindow::MHw(textureID);
MHwindow& MainWindow = MHwindow::instance();
----------------------------------------

and....this is the retrun error:

In function `Z41__static_initialization_and_destruction_0ii':
undefined reference to `MHwindow::MHwindow(unsigned int)'


I'm trying to pass a reference to constructor.

:-(
 
M

Manuel

Mateusz said:
But MHwindow ctors are private :)


Because is singleton, they must be private.
If I delete all "&", it work, so the problem is my use of reference...
 
D

Daniel T.

Manuel said:
Hi...yet, another problem with references...sorry...

This is my singleton header:

-----------------------------------------
class MHwindow {
private:
static MHwindow MHw;

GLuint texture;

//Constructor is private, because this is a singleton
MHwindow(GLuint &);
MHwindow& operator=(MHwindow&); // Disallowed
MHwindow(const MHwindow&); // Disallowed

public:
static MHwindow& instance() { return MHw; }

void setTexture(GLuint);
GLuint getTextures();
};
----------------------------------------

This is my singleton cpp file:

----------------------------------------
MHwindow::MHwindow(GLuint & textur)
{
pngInfo texInfo;
textur = pngBind("pippo.png", PNG_NOMIPMAP, PNG_ALPHA, NULL, GL_CLAMP,
GL_NEAREST, GL_LINEAR);
}

void MHwindow::setTexture(GLuint i){texture = i;};
GLuint MHwindow::getTextures(){return texture;};

----------------------------------------

this is the usage I'm trying:
----------------------------------------
GLuint textureID;
MHwindow MHwindow::MHw(textureID);
MHwindow& MainWindow = MHwindow::instance();
----------------------------------------

What file is the above code in?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top