Stop this now.
Stop this now.
hasafraggin shizigishin oppashigger...
There's something to a #include file.c that makes me shiver.Originally posted by Nick
I do this all the time. Usually when I'm using templates or I'm using inline functions.
But hey! that's your choice.
I don't see the need for you to do this for templates. If you want to have your templates defined in a different file, that's fine. But it's a much better practice to have them added to the project on that case.
As for inline functions, I don't get it. Why the heck you want to an include statement for a .c file that defines inline functions, if the compiler will replace all calls to those functions within that same code file?
Finally, if all else fails, what's taken your from renaming those files to .h and feel a little better about it?
Regards,
Mario Figueiredo
Using Borland C++ Builder 5
Read the Tao of Programming
This advise was brought to you by the Comitee for a Service Packless World
Well you can bash me if you like.
Go ahead.
All men are created equal. But some are more equal than others.
Visit me at http://www.angelfire.com/my/billholm
Right now, none of the compilers I know of will allow you to write template code will compile in the .cpp because the compiler needs to know the types to create the object file. For example try to compile thisI don't see the need for you to do this for templates. If you want to have your templates defined in a different file, that's fine.
That's why the stl and most template code does something like thisCode:// tmp.h template<class T> class Tmp { Tmp(); }; // tmp.cpp #include "tmp.h" template<class T> Tmp<T>::Tmp() { }
Code:// tmp.h template<class T> class Tmp { Tmp(); }; #include "tmp.cpp" // tmp.cpp template<class T> Tmp<T>::Tmp() { }If the whole class is inline then it's probably better to have the implementation in a different file. I guess it really depends on what your doing.As for inline functions, I don't get it. Why the heck you want to an include statement for a .c file that defines inline functions, if the compiler will replace all calls to those functions within that same code file?
Someone might be tempted to include the .h file which would be bad because you only want the class definition to include the .cpp file.Finally, if all else fails, what's taken your from renaming those files to .h and feel a little better about it?
I'm learning about virtual(polymorhism, something like that).
Compiler: MingW(IDE: Bloodshed Dev-C++ 4.01)
Web Site: Zoo Crew
Forums: Zoo Boards
E-mail: [email protected]
"Do you wanna go to jail or do you wanna go home?!?!" - Alonzo(Training Day)