Grouped CPP files

This is a discussion on Grouped CPP files within the C++ Programming forums, part of the General Programming Boards category; How do I get cpp files to interact with other cpp files? Like, say if I make a massive game, ...

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    141

    Grouped CPP files

    How do I get cpp files to interact with other cpp files? Like, say if I make a massive game, how do I use multiple cpp files together?

  2. #2
    Registered User
    Join Date
    Jul 2004
    Posts
    222
    What platform are you building your game in? I think you would include the needed header files that encapsulates the source files, then build it together in a single project.

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    141
    Visual C++

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    In Visual C++ you have "solutions" which contain "projects" which then contain, well, whatever is necessary. So you would make one project with a lot of .cpp files in it.

  5. #5
    Registered User
    Join Date
    May 2008
    Posts
    141
    Quote Originally Posted by tabstop View Post
    In Visual C++ you have "solutions" which contain "projects" which then contain, well, whatever is necessary. So you would make one project with a lot of .cpp files in it.
    I know, but wouldn't you just have to compile that as a dll? I mean I don't know how dlls work with exes or anything so..

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Why are we talking about dll's all of a sudden?

  7. #7
    Registered User
    Join Date
    May 2008
    Posts
    141
    Quote Originally Posted by tabstop View Post
    Why are we talking about dll's all of a sudden?
    Cause thats the only thing I can think about that you can compile as a whole project???

    :S

  8. #8
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    That's ... interesting. It takes real work to get a DLL, whereas it takes no work at all to get a normal executable. (File -> New Project -> (whatever kind of project you want); add all the source files to the project by right-clicking on the name of the project; hit F7 and you're done.)

  9. #9
    Registered User
    Join Date
    May 2008
    Posts
    141
    Well.. at least tell me how executables grab dlls

  10. #10
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    I'd say at this point you're not ready to write a massive game. You need to get a basic book on C++ that explains these things.

  11. #11
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Or, perhaps, Help -> Contents and go through some walkthroughs, or the "getting started" tour.

  12. #12
    Registered User
    Join Date
    May 2008
    Location
    Paris
    Posts
    248
    #include the corresponding header file (.h) in the .cpp file, or in another .cpp file.

    .cpp files are simply there to contain the code of what you have declared in a .h file, so it doesn't make sense to include the .cpp files. The header files are your interface.

  13. #13
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,479
    Like MarkZWEERS suggested:

    // header file
    Code:
    #ifndef FOO_H
    #define FOO_H
    
    class Foo
    {
    public:
       Foo();
    };
    
    #endif
    // .cpp file
    Code:
    #include "foo.h"
    #include <iostream>
     
    int main()
    {
       Foo fo;
      
     return 0;
    }
    I'm just trying to be a better person - My Name Is Earl

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Passing variable between cpp files
    By Todd88 in forum C++ Programming
    Replies: 28
    Last Post: 12-03-2008, 06:01 PM
  2. Error opening files in a different dir
    By Ozzie in forum C++ Programming
    Replies: 3
    Last Post: 10-09-2008, 06:55 AM
  3. Working with muliple source files
    By Swarvy in forum C++ Programming
    Replies: 1
    Last Post: 10-02-2008, 08:36 AM
  4. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM
  5. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21