Quantcast
Channel: Is it a good practice to place C++ definitions in header files? - Stack Overflow
Viewing all articles
Browse latest Browse all 18

Is it a good practice to place C++ definitions in header files?

$
0
0

My personal style with C++ has always been to put class declarations in an include file and definitions in a .cpp file, very much like stipulated in Loki's answer to C++ Header Files, Code Separation. Admittedly, part of the reason I like this style probably has to do with all the years I spent coding Modula-2 and Ada, both of which have a similar scheme with specification and body files.

I have a coworker, much more knowledgeable in C++ than I, who is insisting that all C++ declarations should, where possible, include the definitions right there in the header file. He's not saying this is a valid alternate style, or even a slightly better style, but rather this is the new universally-accepted style that everyone is now using for C++.

I'm not as limber as I used to be, so I'm not really anxious to scrabble up onto this bandwagon of his until I see a few more people up there with him. So how common is this idiom really?

Just to give some structure to the answers: Is it now The Way™, very common, somewhat common, uncommon, or bug-out crazy?


Viewing all articles
Browse latest Browse all 18

Latest Images

Trending Articles





Latest Images