Thread: compilation problems with static data member

  1. #1
    Registered User
    Join Date
    Aug 2008

    compilation problems with static data member

    I am getting some problems with compiling the following code.
    It gives me the following error. I think its ver staright forward and its just that I am missing something. pls help.

    I want to access statis data member which is an array of some other class type.
    error message:

    CalculateMovieSimilarity.cpp.text+0x3ce): undefined reference to `CalculateMovieSimilarity::ifileObject'
    CalculateMovieSimilarity.cpp.text+0x4a7): undefined reference to `CalculateMovieSimilarity::ifileObject'
    CalculateMovieSimilarity.cpp.text+0x547): undefined reference to `CalculateMovieSimilarity::ifileObject'
    collect2: ld returned 1 exit status

    and following is the code snippet

    class IndexFileObject
        public: int count;
                int referencebytepos;
                int relativebytepos[DATEINTERVALS];
    class CalculateMovieSimilarity
        public: static string indexfilename;
                static IndexFileObject ifileObject[17770];            
                static void createifileObject();
    void CalculateMovieSimilarity::createifileObject(){

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Northern Virginia/Washington DC Metropolitan Area
    Do you have an actual instance of that static class data member somewhere in your source file?
    CalculateMovieSimilarity::IndexFileObject ifileObject[17770];
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  2. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM
  3. Static member data inaccessible
    By BSTRhino in forum C++ Programming
    Replies: 2
    Last Post: 01-10-2002, 08:28 PM
  4. Replies: 2
    Last Post: 09-29-2001, 03:36 PM
  5. How do I base size of arrays on annother number?
    By Dual-Catfish in forum C++ Programming
    Replies: 15
    Last Post: 09-25-2001, 01:31 PM
Website Security Test