What if...???
-
What do you think if I implement my classes in .h files instead of dividing the declarations in .h files and the implementation in .cpp? Is this a bad programming style or it will bother the compiler?
-
What do you think if I implement my classes in .h files instead of dividing the declarations in .h files and the implementation in .cpp? Is this a bad programming style or it will bother the compiler?
it wont bother that much the compiler if you do it correctly. however, it is a bad habit to do so. we generally put into headers only declarations, other includes, class definitions, and the implementation code into deparated .cpp files...
TOXCCT >>> GEII power
[toxcct][VisualCalc 2.20] -
What do you think if I implement my classes in .h files instead of dividing the declarations in .h files and the implementation in .cpp? Is this a bad programming style or it will bother the compiler?
Hello, It's a bad (C/C++) programming practice and it will bother the linker if you include the header in more than one place. (Multiple defined symbols...). Besides that, if you place all your code in header files (no *.cpp file(s)) you'll not be able to create object files and executable code... If you are talking about templates (I assume you are not), then you have to put all the code in a *.inl document or in the header file. Hope this helps you. :) Behind every great black man... ... is the police. - Conspiracy brother Blog[^]
-
What do you think if I implement my classes in .h files instead of dividing the declarations in .h files and the implementation in .cpp? Is this a bad programming style or it will bother the compiler?
bad idea, if you change the implementation all file dependant on that header file will be recompiled. Also, I don't think the debugger will be able to step in the code. anyway, bad idea, I sure others will give you other reasons why.
Maximilien Lincourt Your Head A Splode - Strong Bad
-
it wont bother that much the compiler if you do it correctly. however, it is a bad habit to do so. we generally put into headers only declarations, other includes, class definitions, and the implementation code into deparated .cpp files...
TOXCCT >>> GEII power
[toxcct][VisualCalc 2.20] -
What do you think if I implement my classes in .h files instead of dividing the declarations in .h files and the implementation in .cpp? Is this a bad programming style or it will bother the compiler?