C++ header files

This is a discussion on C++ header files within the C++ Programming forums, part of the General Programming Boards category; I am a newbie to programming and don't have a clue how to make header files for my fuctions and ...

  1. #1
    Unregistered
    Guest

    Unhappy C++ header files

    I am a newbie to programming and don't have a clue how to make header files for my fuctions and classes
    how do i use the #ifndef statement and the others like it

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    10
    the best way to learn programming is by reading books
    but i'll try to help you with your question
    in a header fileyou define the function(prototype) or the class
    like:
    void Example(); // function prototype
    class Example
    {
    // define your class here
    };
    If You've Be Biten By DaRk$nAkE The Only Things You Will See R Bytes

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    3
    The compiler will only compile code between #ifndef xxx and #endif, if it hasn't encountered #define xxx before.It's sometimes used to stop the same header file being included twice:
    #ifndef __STDIO_H
    #define __STDIO_H
    ...
    #endif

    You can use define to include lines for debugging or not:
    #define debug

    int x = 5;
    #ifdef debug
    cout << "x is " << x << endl;
    #endif

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. #include header files or .cpp files?
    By DoctorX in forum C++ Programming
    Replies: 3
    Last Post: 12-23-2006, 11:21 AM
  3. classes and header files
    By Drake in forum C++ Programming
    Replies: 8
    Last Post: 11-30-2006, 06:12 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM

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