| | |
Classes and header files
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
One good reason would be to hide the implementation. If any changes need to be made to the implementation then it makes sense to separate it into a single file so that any code that uses the header doesn't need to be recompiled. If you place declarations in a header file you can more easily break the one definition rule, so separating declarations and definitions will make writing correct code easier. If you place the entire class in your headers then compilation can also take longer.
It depends on the compiler. Generally the files will be compiled in the order that they're listed when the compiler is run.
>>And what's the one declaration rule?
One "definition" rule. It means that you can declare an object as much as you want because a declaration only says "Hey, I exist", but you can only define it once because a definition actually makes the object exist by allocating memory and calling constructors. If there are multiple definitions then you'll get an error.
>>And what's the one declaration rule?
One "definition" rule. It means that you can declare an object as much as you want because a declaration only says "Hey, I exist", but you can only define it once because a definition actually makes the object exist by allocating memory and calling constructors. If there are multiple definitions then you'll get an error.
![]() |
Similar Threads
- Working with header files ??? (C)
- Header files (C++)
- Header organization (base and derived classes) (C++)
- Please some one help me in this code (C++)
- Total Newbie Could Use A Pointer In The Right Direction (C++)
- c vs h header files... (C)
Other Threads in the C Forum
- Previous Thread: Creating a Coordiantion (Grid Based) System for a text-based game.
- Next Thread: Reciving data w/ a network app
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays asterisks bash binarysearch calculate centimeter char convert copyanyfile copyimagefile copypdffile cprogramme createcopyoffile csyntax directory dynamic fflush file fork frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators infiniteloop initialization interest km lazy linked linkedlist linux linuxsegmentationfault list locate logical_drives match matrix meter microsoft motherboard multi mysql number open opendocumentformat opensource owf pattern pdf performance pointer pointers posix power problem probleminc program programming pyramidusingturboccodes read recursion recv repetition scanf scheduling scripting segmentationfault send shape socketprograming spoonfeeding stack standard string strings structures suggestions systemcall test testautomation unix user variable voidmain() wab win32api windows.h





