Thread: C++ header files

  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, 12:21 PM
  3. classes and header files
    By Drake in forum C++ Programming
    Replies: 8
    Last Post: 11-30-2006, 07:12 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM