Thread: Own Header Files

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    2

    Unhappy Own Header Files

    ((Sorry, if smth like this was posted, but I didn't find anything with search-sorry and for bad English))
    Plz don't think I'm a total noob, because I asked this questions:
    1.
    I created my own header file which includes my functions for a new game. I saved it in a "include" file of C++(where are the iostream, stdlib etc.). Now my problem is that I don't know how to use it if it's not in that file. This really a problem for me, but if I'd create a lots of .h/.hpp files, thre will be a total mess .
    2.
    Which is better for C++: .h or .hpp files?

  2. #2
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970
    It is normal to create dozens of header files for a big project.

    If you do not wish to copy your header files to a new project directory each time you start a new project, just put them in your compiler's default include directory.

    Whether .h or .hpp is used is often decided by which compiler you're using. I use .h.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > just put them in your compiler's default include directory.
    No, don't do that - not unless you like losing all your work when you upgrade / patch / change your compiler.

    Create separate 'myinc' and 'mylib' directories for all the useful stuff you create and want to re-use from project to project.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

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