Thread: help with static linkage error of member function

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    7

    help with static linkage error of member function

    Here is the code:

    static const char* Token:rintableForm(int tokenType)

    if(tokenType == 1) return "ASSIGN";
    else if(tokenType == 2) return "PLUS";
    else if(tokenType == 3) return "TIMES";
    else if(tokenType == 4) return "MINUS";
    else if(tokenType == 5) return "DIVIDE";
    else if(tokenType == 6) return "EQ";
    else if(tokenType == 7) return "GT";
    else if(tokenType == 8) return "LT";
    else if(tokenType == 9) return "NEQ";
    else if(tokenType == 10) return "AND";

    Here is the error:

    tokenizer.cpp:20: cannot declare member function `static const char*
    Token:rintableForm(int)' to have static linkage
    Can anyone help me with this please. I am not sure how to fix this or what to do.

  2. #2
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Remove static off of your defintion, you only need it in the declaration... eg,

    Code:
    class A
    {
     public:
        A() {m_i = 0 };
        static const int myfunc();
    
     private:
        int m_i;
    }
    
    const int A::myfunc()
    {
        return 0;
    }

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    7
    thanks a bunch eibro. removing static worked

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-13-2011, 08:28 AM
  2. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  3. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  4. seg fault at vectornew
    By tytelizgal in forum C Programming
    Replies: 2
    Last Post: 10-25-2008, 01:22 PM
  5. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM