Hi,
I am writting a class that uses singletons, but I am
running into a link problem. I have searched the Internet
and came up with some issues regarding the error, but
none specific. So, I decided to have you guys look at
it and see if there is something that I am doing wrong.
Here is the error message:
CSingleton.h
Display All
"CSingleton.h"
Display All
Main.cpp
Display All
Ok, so what I am not seeing that is causing the LNK
error?! From several sources that I have been pulling
from off the Internet, this is the "right way", right?
Thanks again,
Sabrina.
I am writting a class that uses singletons, but I am
running into a link problem. I have searched the Internet
and came up with some issues regarding the error, but
none specific. So, I decided to have you guys look at
it and see if there is something that I am doing wrong.
Here is the error message:
CSingleton.h
Source Code
"CSingleton.h"
Source Code
- #include "CSingleton.h"
- CSingleton *CSingleton::m_pInstance = NULL;
- CSingleton::~CSingleton()
- {
- }
- CSingleton *CSingleton::GetInstance( void )
- {
- if ( m_pInstance == NULL )
- {
- m_pInstance = new CSingleton(); // BAD way of doing this.
- // m_pInstance = std::auto_ptr<CSingleton> CSingleton; // MUCH better way!
- }
- return ( m_pInstance );
- }
- void CSingleton::PrintMessage( void )
- {
- std::cout << "Hello there singleton!" << std::endl;
- }
Main.cpp
Source Code
Ok, so what I am not seeing that is causing the LNK
error?! From several sources that I have been pulling
from off the Internet, this is the "right way", right?
Thanks again,
Sabrina.