Question About Headers

This is a discussion on Question About Headers within the C++ Programming forums, part of the General Programming Boards category; I am making my own header file to use for my program.. Can I initialize my variables to be used ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    673

    Exclamation Question About Headers

    I am making my own header file to use for my program.. Can I initialize my variables to be used by the program in my header. Instead of listing every variable in every .cpp is it possible to just include the header with all this info already in it? Thanks in advance.

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    What sort of variables? It's better that header files are left to the definition of things that are used throughout your program, while source files are left to their implementation.

    >> Instead of listing every variable in every .cpp

    In what case are you facing is this necessary? If they are merely things like const's and #define's, then certainly it could be appropriate.

  3. #3
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    OH, ok, because in the program I a writing I have about 20 array variables and 15 non arrays, and I have to put them in EVERY single one of my .cpp, but I am using my header to init all the other headers like iostream, conio,time, and windows.h, and was wondering if there is a way around putting all those variables in each .cpp like in a header or somthing but from what you say you cant.

    EDIT: I am really new to the programming thing so I dont know all the rules.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 04:49 AM
  2. Headers that use each other
    By nickname_changed in forum C++ Programming
    Replies: 7
    Last Post: 10-03-2003, 05:25 AM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 10:47 PM
  4. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  5. Help with headers (conio.h etc)
    By ofthedove in forum C++ Programming
    Replies: 2
    Last Post: 02-24-2003, 02:44 PM

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