Thread: Error: "illegal call of non-static member function"

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    32

    Error: "illegal call of non-static member function"

    I'm calling a non-static member function from a function declared as follows:

    Code:
    LRESULT nwindowproc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam)
    The function is in the implementation file of a control class.

    The documentation for this error says that a static method attempts to call a non-static method ... I don't get it! Why is nwindowproc static??

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Is nwindowproc() a non-static member function of some class?

    If so, you can't use a non-static member function as a window procedure.
    Read this thread as well.

    If you already knew that, then you'll have to clarify your problem by posting the offending code.

    gg

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Post the code that calls nwindowproc().

    Kuphryn

  4. #4
    Registered User
    Join Date
    Jul 2003
    Posts
    32
    Is nwindowproc() a non-static member function of some class?

    nwindowproc() is not a member at all ... it's just there in the cpp ...

    Post the code that calls nwindowproc().

    Well, you caught me. I was trying to use nwindowproc as a callback. Now I see that my problem is all over the forum, seems like I foud something "Big" (weird ... looks like I have a natural tallent for that - I hate it!).

    I was just wondering why the compiler says my function is static even if it is not declared as "static".

    And ... I'll search the boards next time.

  5. #5
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    >> a static method attempts to call a non-static method

    That may be the most common reason for the error, but not necessarily the only way to cause the error.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. const correctness and static member variables
    By cunnus88 in forum C++ Programming
    Replies: 2
    Last Post: 02-21-2008, 05:26 PM
  2. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 05:42 PM
  3. temperature sensors
    By danko in forum C Programming
    Replies: 22
    Last Post: 07-10-2007, 07:26 PM
  4. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  5. Multiple types in lists, vectors or arrays.
    By megatron09 in forum C++ Programming
    Replies: 20
    Last Post: 08-31-2006, 01:54 PM