C++ help needed.

This is a discussion on C++ help needed. within the C++ Programming forums, part of the General Programming Boards category; Iím teaching myself C++ and I don't have a strong knowledge in C++ so please understand that I will ask ...

  1. #1
    Registered User
    Join Date
    Jul 2010
    Location
    U.S
    Posts
    7

    Unhappy C++ help needed.

    Iím teaching myself C++ and I don't have a strong knowledge in C++ so please understand that I will ask you VERY basic question. So, consider me as a beginner in C++ if you will. I am taking a class and need help with the following error message.

    When creating a class, the convention seems to be to put the class declaration in a header file and put the member functions in a .cpp file. That part I do not understand.

  2. #2
    Registered User
    Join Date
    Jul 2010
    Posts
    4
    I believe this is because when including header files, the #include statement simply gets replaced with the contents of the header files, meaning including definitions in a header file will get declared repeatedly and cause compiler errors.

    However the definition must be somewhere, else you will also get errors for undefined functions, so they are dumped in a .cpp file, all of the .cpp files are compiled individually to .obj files and then linked together, so the functions are not defined more than once.

    I could be wrong, though, so you're best to wait for somebody with more knowledge to reply...

  3. #3
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650
    That's not an error message?

  4. #4
    Registered User
    Join Date
    Jul 2010
    Location
    U.S
    Posts
    7
    fatal error C1083: Cannot open include file: 'reservationRecord.h': No such file or directory
    Yes, I understand that I have to move your header file to the same directory your main source code is located. I know what the header file is but what i don't know is the directory file. will you please explain to me in more detail how I would know the directory it belongs in. can anyone give me an example of what this is saying?

  5. #5
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650
    Where is the file? Where is it compared to the rest of your files? Did you add it to your project? If you don't understand how your filesystem works, how can you expect to be a programmer?

  6. #6
    Registered User
    Join Date
    Jul 2010
    Location
    U.S
    Posts
    7
    That is correct. I don't understand how the filesystem works. can you explain it?

  7. #7
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650

  8. #8
    Registered User
    Join Date
    Jul 2010
    Location
    U.S
    Posts
    7
    I am looking for help in every place I can. Can you help me?

  9. #9
    Registered User
    Join Date
    Jul 2010
    Location
    U.S
    Posts
    7
    when you said file system is this what your talking about?

    Code:
    
    function
    prototypes
    function #1
    function #2
    function #3
    #include <iostream>
    using namespace std;
    void simon(int);
    double taxes(double);
    int main()
    {
    ...
    return 0;
    }
    void simon(int n)
    {
    ...
    }
    double taxes(double t)
    {
    ...
    return 2 * t;
    }

  10. #10
    Registered User
    Join Date
    Jul 2010
    Location
    U.S
    Posts
    7
    Can you help me with my problem?

  11. #11
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Don't teach yourself C++. Teach yourself computers first. You need some technical knowledge of how computers work in order to be an effective programmer, especially in C++.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  12. #12
    Registered User
    Join Date
    Jul 2010
    Location
    U.S
    Posts
    7
    This is the answer I was looking for.

    It just means that your header file can’t be found. If you put it in the same directory as your cpp file, it should be fine. If you are using Visual Studio, open your project, and open your code file (the cpp file). Then go to the file menu and do a Save As on your CPP file and it will show you the directory where it is saved. Then just be sure to save your .h header file into the same path.

  13. #13
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,614
    Basic filesystem workings. That's why they told you to learn computers first.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. free needed or not?
    By quantt in forum Linux Programming
    Replies: 3
    Last Post: 06-25-2009, 09:32 AM
  2. C Programmers needed for Direct Hire positions
    By canefan in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 09-24-2008, 11:55 AM
  3. C++ help needed
    By Enkindu in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 08-31-2004, 11:24 PM
  4. help needed with array
    By noob2c in forum C Programming
    Replies: 5
    Last Post: 05-24-2003, 09:02 AM
  5. error with function, help needed quick
    By chris285 in forum C++ Programming
    Replies: 3
    Last Post: 04-30-2003, 08:31 AM

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