Function Declaration - help needed

This is a discussion on Function Declaration - help needed within the C++ Programming forums, part of the General Programming Boards category; For some reason I'm not able to define the second function --> node* previous(void); in the .cpp file It only ...

  1. #1
    Unregistered
    Guest

    Function Declaration - help needed

    For some reason I'm not able to define the second function --> node* previous(void); in the .cpp file It only works for me when i define it In-Line.

    I tried it as :

    --- The .cpp ---

    node* TheMain:revious(void){
    node *pn;

    return pn;
    }


    Errors:

    - error C2143: syntax error : missing ';' before '*'
    - error C2501: 'node' : missing storage-class or type specifiers
    - error C2501: 'previous' : missing storage-class or type specifiers
    - error C2556: 'int *__thiscall TheMain:revious(void)' : overloaded function differs only by return type from 'struct TheMain::node *__thiscall TheMain:revious(void)'


    --------------
    ---The .h---

    class TheMain{
    private:
    struct node{
    FileM *flm;
    int counter;
    node *next;
    };

    node *top, *current, *prev;
    int number_nd;

    ////////STRUCT NODE PRIVATE FUNCTIONS//
    void gostart(void);

    node* previous(void); // CANT DEFINE THIS IN THE .CPP file

    public:
    //Stuff
    };

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    Are you including the relevant headers in your cpp file?

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    223
    Make this declaration outside of the class declaration..... this way the other modules outside of TheMain can have knowledge of node...

    Code:
    //TheMain.h
    
    
    struct node{ 
        FileM *flm; 
        int counter; 
        node *next
    };
    
    class TheMain{
    
      .....
      node* pHead;
      node* prevoius;
      ....
    
    }
    zMan

  4. #4
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    ..or do -

    TheMain::node* TheMain::previous(void){
    node *pn;

    return pn;
    }

    in your cpp file.
    Last edited by Sorensen; 02-20-2002 at 04:05 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 01:28 PM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 12:03 PM
  4. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 05:45 AM
  5. errors initializing D3D
    By Vacation Guy in forum C++ Programming
    Replies: 3
    Last Post: 08-07-2005, 12:20 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21