error lnk2001: unresolved external symbol

Posted on 2006-05-05
Last Modified: 2010-04-17
I have a class with the following code. It is one of the classes in my project that i'm trying to compile into a dll.

class myClass
      static myClass* getInstance();
      static myClass* ptr;

When I try to compile it, I get this error lnk 2001: unresolved external symbol "private: static class myClass* myClass::ptr(ptr@myClass@@0PAV1@A)

Can anyone help with this?
Question by:hybrid79
    1 Comment
    LVL 32

    Accepted Solution

    Two things:

    1) Add the ";" after your class.
    2) You must initialize the static member variable in the global namespace.

    class myClass
          static myClass* getInstance();
          static myClass* ptr;

    myClass * myClass::ptr = NULL;

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Title # Comments Views Activity
    countTriple  challenge 8 59
    mirrorEnds challenge 6 66
    count7 challenge 12 52
    stringclean challenge 26 43
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now