Thread: Important Note(A post to end all newbie topics concerning......)

  1. #16
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    Stop this now.
    hasafraggin shizigishin oppashigger...

  2. #17
    Registered User Mario's Avatar
    Join Date
    May 2002
    Posts
    317
    Originally posted by Nick

    I do this all the time. Usually when I'm using templates or I'm using inline functions.
    There's something to a #include file.c that makes me shiver.
    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

  3. #18
    Registered User billholm's Avatar
    Join Date
    Apr 2002
    Posts
    225

    Talking

    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

  4. #19
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    Posts
    2,595
    No please don't, not on the C++ board. This is stupid.

    [Please] Stop this now.
    ditto
    Kermi3

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

  5. #20
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    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.
    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 this

    Code:
    // tmp.h
    template<class T>
    class Tmp {
           Tmp();
    };
    
    // tmp.cpp
    #include "tmp.h"
    template<class T>
    Tmp<T>::Tmp()
    {
    }
    That's why the stl and most template code does something like this

    Code:
    // tmp.h
    template<class T>
    class Tmp {
           Tmp();
    };
    
    #include "tmp.cpp"
    
    // tmp.cpp
    
    template<class T>
    Tmp<T>::Tmp()
    {
    }
    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?
    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.

    Finally, if all else fails, what's taken your from renaming those files to .h and feel a little better about it?
    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.

  6. #21
    Registered User
    Join Date
    Apr 2002
    Posts
    156
    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)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. need some help with last part of arrays
    By Lince in forum C Programming
    Replies: 3
    Last Post: 11-18-2006, 09:13 AM
  3. New compiler - Weird errors -,-.
    By Blackroot in forum C++ Programming
    Replies: 8
    Last Post: 08-27-2006, 07:23 AM
  4. Another multi boot Newbie Linux post!
    By Bajanine in forum Tech Board
    Replies: 4
    Last Post: 06-18-2004, 09:19 PM
  5. Next Question...
    By Azmeos in forum C++ Programming
    Replies: 3
    Last Post: 06-06-2003, 02:40 PM