Thread: Do cpp Files get Included Automatically in VS?

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    127

    Do cpp Files get Included Automatically in VS?

    Hi,

    I've copied this example program out of a book, and it's made up of 3 files:

    Fract.h, FloatFract1.cpp, and Fract.cpp

    I've been using VS Express to put it all together into a project. This may be a stupid question, but when you build your solution, do all the cpp files get put together automatically?

    I understand that you have to put #include "Fract.h" or the same for your other header files. But I've noticed that there's nothing like: #include "FloatFract1.cpp" or #include "Fract.cpp" in the files. So do .cpp files just get included together automatically?

    Thanks.

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by bengreenwood View Post
    Hi,

    I've copied this example program out of a book, and it's made up of 3 files:

    Fract.h, FloatFract1.cpp, and Fract.cpp

    I've been using VS Express to put it all together into a project. This may be a stupid question, but when you build your solution, do all the cpp files get put together automatically?

    I understand that you have to put #include "Fract.h" or the same for your other header files. But I've noticed that there's nothing like: #include "FloatFract1.cpp" or #include "Fract.cpp" in the files. So do .cpp files just get included together automatically?

    Thanks.
    Compilation is a two step process. In step #1, individual cpp files are compiled to produce obj (object) files. In step #2, the linker combines these obj files together to produce an executable.

    It's step #2 where the cpp files get "put together automatically." And yes, if the relevant cpp files are included in the project, they will be used to produce the final program.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    Registered User
    Join Date
    Sep 2007
    Posts
    127
    Cool, informative reply. Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with loading files into rich text box
    By blueparukia in forum C# Programming
    Replies: 3
    Last Post: 10-19-2007, 12:59 AM
  2. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. Many Header Files
    By matth in forum C++ Programming
    Replies: 3
    Last Post: 03-08-2005, 02:45 PM
  5. compiler won't find the included opengl files
    By cerin in forum C++ Programming
    Replies: 2
    Last Post: 03-06-2005, 12:52 AM