Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: c++ programming:  (Read 2878 times)

0 Members and 1 Guest are viewing this topic.

T-Wave

    Topic Starter


    Rookie

    c++ programming:
    « on: September 09, 2008, 03:35:29 PM »
    Hi,

    when I compile the code below, I get the following error messages:

    [linker error] undefined reference to `sample_class::UsingFile'
    ld returned 1 exit status
    [Build Error]  ["Class] Error 1 



    How do I solve this problem? Thanks.



    Code: [Select]
    class sample_class
    {
       
        public:
            sample_class()
            {
                UsingFile = 0;
            }
           
            ~sample_class()
            {
              --UsingFile;
            }
           
            static bool IsFileInUse();
           
                   
        private:
            static int UsingFile;
           
    };



    bool sample_class::IsFileInUse()
    {
               if(UsingFile != 0)
               {
                  cout << "File in use" << endl << endl;
                  return (true);
               }

    }


    int main(int argc, char *argv[])
    {

         
        system("PAUSE");
        return EXIT_SUCCESS;
    }