Thread: What /what not to put in header files

  1. #1
    Just
    Guest

    What /what not to put in header files

    This has been bugging me for a while, but I'm reasonably confident I've got things figured out. Here's how I plan to do things from now on.

    IN HEADERS:

    - struct definitions
    - prototypes of functions that are to be used by other files
    - declaration of variables that other files should have access to (hopefully not too many)

    IN C FILE:

    - prototypes of "helper" functions (ie functions not to be used by other files)
    - global variable declarations that should not be accessed outside this file
    - implementations of each function (obviously)



    The variables and functions declared in the header should also have the docs (ie describe how the functions are used in the header, not the c file). The functions and variables declared in the C file should all be static.

    Okay, that's it. I'm trying to convert my (currently lousy) C programming into a more object-oriented style, where the headers contain just an interface. How does all this sound? In my previous programs, I've put ALL function prototypes in the header file, but I've come to the conclusion that this is a bad idea. Have I screwed anything up? Left anything out?

    Thanks,

    Just

  2. #2
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    > - prototypes of functions that are to be used by other files
    erm

    Just reread, heh..
    That parts right.

    You look like you're coming along btw.

    Just make sure no code goes in a header, and you'll be looking good.
    The world is waiting. I must leave you now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. about #include files and header files
    By bulletbutter in forum C++ Programming
    Replies: 9
    Last Post: 04-18-2008, 10:24 AM
  2. Creating header files
    By histevenk in forum C++ Programming
    Replies: 14
    Last Post: 10-17-2007, 08:02 PM
  3. Many Header Files
    By matth in forum C++ Programming
    Replies: 3
    Last Post: 03-08-2005, 02:45 PM
  4. Header files
    By Jez_Master in forum C++ Programming
    Replies: 2
    Last Post: 04-08-2002, 07:56 AM
  5. more header files
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 10-28-2001, 01:56 PM