Thread: Pls help : Function declaration outside structure definition.

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    1

    Lightbulb Pls help : Function declaration outside structure definition.

    Dear all,

    I am following an opensource project and came across following code segment
    Code:
    struct MState
    {
      uint8_t sVert;
      uint8_t sHorz;
      static uint8_t event;
      void init(){sVert=sHorz=0;};
      
      void checkExit(uint8_t event,bool immediate=false);
      //!/ schltet horiz weiter zum naechsten menu. 
      //!/ entry    initialisiert, 
      //!/ key_exit schaltet in zwei stufen zurueck zuerst sub=0, dann popmenu
      void checkChain( uint8_t curr, MenuFuncP *menuTab, uint8_t size);
      //!/ schltet vertik weiter zum naechsten submenu. 
      //!/ entry    initialisiert, 
      //!/ keine reaktion auf exit
      uint8_t checkVert( uint8_t maxVert);
      //!/ schltet horiz weiter zum naechsten subsubmenu. 
      //!/ entry    initialisiert, 
      //!/ keine reaktion auf exit
      uint8_t checkHorz( uint8_t myVert, uint8_t maxHoriz);
    };
    uint8_t MState::event;
    what i dont understand is since the function "MState::event" is not declared in the structure itself why its declared outside. ? assuming that "MState::event" refers to a function not the "static uint8_t event" variable declared in the structure.

    If this is a common practice please let me know the exact name for this kind of work..

    Thanks a lot in advance and I'm really sorry if I'm driving you guys nuts asking silly question because of my lack of knowledge.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    This is C++, not C. We'll have it moved (don't post it there, someone will move it).


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. declaration and definition
    By sugarfree in forum C++ Programming
    Replies: 2
    Last Post: 04-11-2010, 06:53 AM
  2. Declaration vrs Definition
    By curlious in forum C++ Programming
    Replies: 1
    Last Post: 09-03-2004, 07:13 PM
  3. Templated function (declaration and definition)
    By Eibro in forum C++ Programming
    Replies: 2
    Last Post: 03-11-2003, 08:07 PM
  4. Declaration/Definition ??
    By Manish in forum C++ Programming
    Replies: 4
    Last Post: 03-03-2002, 11:37 AM
  5. function definition with structure node
    By Peachy in forum C Programming
    Replies: 2
    Last Post: 12-10-2001, 10:49 PM

Tags for this Thread