![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#21 |
|
Hobbyist Programmer
Join Date: Jul 2005
Posts: 158
Rep Power: 0
![]() |
@DaWei I have seen this done in many of my programming books and yes I am an ameteur but truly it is a copy and paste operation I simply seperate it for my sake in the end it doesn't matter if it is in the original source or not. As for compilers I have a basic understanding of them. The files are compiled seperatly and linking puts them in to one file ultimately it all becomes one eventually.
__________________
Geeks may not be cool now but in the long run they prosper. |
|
|
|
|
|
#22 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Toss your books if they recommend code in the header files. This does not apply to class definitions. If you're putting your functions in header files for modularity, you are going about modularity the wrong way. If your personal preference is to do things improperly, that's your business. Please do not spread the poison to new people trying to learn the best ways, not the worst ways.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#23 |
|
Hobbyist Programmer
|
I dont see what the big problem is, code still works in .h even if it is the wrong type.
If books, and tutorials all do it, its not that bad.
__________________
Hoes telling me to calm down but I'm like fuck that shit!
|
|
|
|
|
|
#24 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Books and tutorials don't all do it. The problem has been explained here. In code of any complexity if will cause multiple definition errors. Please remove the sack long enough to read the explanations, and please refrain from condoning bad practice.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#25 | |
|
SEXY SHOELESS GOD OF WAR!
![]() Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,295
Rep Power: 5
![]() |
Quote:
Some links are here, here and here. Declarations: function prototypes, class declarations, variable declarations (ie with extern keyword). Definitions: function declarations which include a function body, class or variable declarations which associate a name with storage for an object, optionally initializing it.
__________________
Java? Rant? Me? Noooo.... |
|
|
|
|
|
|
#26 | |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
Lectic read your #14 post again, poly is trying to help
![]() Quote:
// stats.h
// character stats header
characterStats :: characterStats(void)
{
strength = 0;
health = 0;
agility = 0;
}![]()
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
|
#27 | |
|
SEXY SHOELESS GOD OF WAR!
![]() Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,295
Rep Power: 5
![]() |
Quote:
I was only responding to the definition vs. declaration statement, thinking he meant 'you' as in a generic term for someone, ie 'one puts definitions in header files' (wrong), rather than a direct 'you', referring to my boo-boo, of which I was unaware. Oops. ![]()
__________________
Java? Rant? Me? Noooo.... |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|