Embarassingly Stupid Question

This is a discussion on Embarassingly Stupid Question within the C++ Programming forums, part of the General Programming Boards category; Despite having been programming in C++ for about a decade, I've never got my head around 'proper' multi-file projects. My ...

  1. #1
    Budding Synth Programmer samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Trefforest
    Posts
    368

    Embarassingly Stupid Question

    Despite having been programming in C++ for about a decade, I've never got my head around 'proper' multi-file projects. My projects have been either completely monolithic or have been linked by #including .cpp files (which I understand is not good practice).

    The thing is, every time I try to do it properly I get errors. I have attatched a simple project to demonstrate what I mean (MSVC++ 6.0). The .h file is included and the .cpp file has been added to the project but it STILL won't compile.

    Maybe you can help.

    http://s40.yousendit.com/d.aspx?id=2...91CA86CY0MEYCK
    MSVC++ 6.0

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Let's assume your header to be named "point.h" instead of "c.h". Then #include "point.h" in c.cpp like it is in t.cpp.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    1) Put your declarations in a .h file.

    2) Include the .h file in any file that uses the names declared in the .h file.

    An include statement just causes the contents of the specified file to replace the include statement. So, when you include the .h file at the top of a .cpp file, the declarations get inserted in the .cpp file.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stupid Question Probably
    By Kyrin in forum C Programming
    Replies: 2
    Last Post: 05-07-2006, 12:51 AM
  2. Replies: 7
    Last Post: 11-03-2005, 11:17 PM
  3. Stupid Question
    By digdug4life in forum C++ Programming
    Replies: 22
    Last Post: 05-17-2005, 11:43 AM
  4. stupid, stupid question
    By xelitex in forum C++ Programming
    Replies: 5
    Last Post: 12-22-2004, 07:22 PM
  5. Stupid question: What does Debugger do?
    By napkin111 in forum C++ Programming
    Replies: 6
    Last Post: 05-02-2002, 10:00 PM

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