Jump to content

Lord Sinister

Member
  • Posts

    2,242
  • Joined

  • Last visited

Posts posted by Lord Sinister

  1. Come on, we've got to have a few programmers on this forum surely? :P

     

    Anyway, basically I'm a little confused on just what I'm supposed to place in header files. I've not done a lot with C++ (no classes, only done a little on them in Java), although I gather that class definitions can go in Header files.

     

    I was initially creating a series of functions in a menus.h file.

     

    Stuff like:

     

    displayMainMenu()
    {
    // Code
    }
    
    displaySubMenu01()
    {
    // Code
    }
    displaySubMenu02()
    {
    // Code
    }
    

     

    However an issue arose when I tried to call a header function from inside the header file, eg:

     

    displayMainMenu()
    {
       displaySubMenu01();
    }
    
    displaySubMenu01()
    {
    // Code
    }
    

     

    I get an error along the lines of "'displaySubMenu01()' was not declared in this scope", where 'displaySubMenu01()' is one of my menu functions, and this error comes up several times for each menu function I call in the first menu function.

     

    After doing some googling, it 'appears' that I should only use a header file for declarations, ie:

     

    void displayMainMenu();

    void displaySubMenu01();

    void displaySubMenu02();

     

    I've also read that I should then use a separate .cpp file as a library file, say menus.cpp, and put the function content in that file. If this is the case, how do I get my main.cpp file to interact with this other menus.cpp file.

     

    Despite some searching all I've been able to read is contradictory information and confusing forum posts. Hopefully someone moderately good with C++ can help. :(

     

    EDIT:

     

    Small update, just created a menus.cpp file (containing the functions themselves) and a menus.h file (containing the function declarations, assuming that's even the right word for this, I've seen the word 'prototype' used to describe this as well). I've moved stuff around, and included menus.h in both menus.cpp and main.cpp.

     

    The program appears to function, but is this the correct way of doing things?

  2. Ah the original Half-Life's soundtrack....it's so difficult to pick a single favourite track for I like many of the tracks.

     

    They all invoke different feelings of nostalgia in me. In a good way.

  3. The last few updates for Minecraft seem to have made it a little bit more unstable. The issues will hopefully be ironed out over the next few days.

     

    On a related note, multiplayer Nether is pretty cool.

×
×
  • Create New...

This website uses cookies, as do most websites since the 90s. By using this site, you consent to cookies. We have to say this or we get in trouble. Learn more.