Click here to Skip to main content
15,907,328 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
C#
class Single
{
private:
   Single();

public:
   static Single& Single::Instance()
   {
      static Single the_instance;
      return the_instance;
   }
};
int main()
{
    cout <<  "Hello World!" << endl;

    Single& instance1 = Single::Instance();
    Single& instance2 = Single::Instance();

    return 0;
}


VB
main.obj : error LNK2019: unresolved external symbol "private: __cdecl Single::Single(void)" (??0Single@@AEAA@XZ) referenced in function "public: static class Single & __cdecl Single::Instance(void)" (?Instance@Single@@SAAEAV1@XZ)
debug\sampleSingletontled.exe : fatal error LNK1120: 1 unresolved externals

What am I doing wrong?
Posted

1 solution

Change
C++
private:
  Single();

to
C++
private:
  Single() {};
 
Share this answer
 
Comments
Member 11279587 2-Dec-14 7:46am    
Thanks!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900