Singleton class

R

Raj

Wrote a piece of code implementing singleton class with private
constructor and static function returing pointer the object.Code is
compiled successfully. But throwing a linking error Singletonclass.exe
: fatal error LNK1120: 1 unresolved externals.
when I tried to create object from main like this
singleton *obj = singleton::Instance();
Would anyone tell me why?
 
T

tropos

Raj said:
Wrote a piece of code implementing singleton class with private
constructor and static function returing pointer the object.Code is
compiled successfully. But throwing a linking error Singletonclass.exe
: fatal error LNK1120: 1 unresolved externals.
when I tried to create object from main like this
singleton *obj = singleton::Instance();
Would anyone tell me why?

Check your Makefile. Sounds like you didnt bring your Singleton.o
object file into the build. Or show us the Singleton.h and
Singleton.cpp code.

Tropos
 
K

Krishanu Debnath

Raj said:
Wrote a piece of code implementing singleton class with private
constructor and static function returing pointer the object.Code is
compiled successfully. But throwing a linking error Singletonclass.exe
: fatal error LNK1120: 1 unresolved externals.
when I tried to create object from main like this
singleton *obj = singleton::Instance();
Would anyone tell me why?

Yes, you are doing something wrong at line no 35.

Krishanu
 
R

Raj

Thanks for ur reply..But the problem was something else.I did not
initialise the static pointer I was using...But got any idea why it was
not detected by the compiier but only during linking?
 

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

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top