Thread: adding a header file in VC 6.0

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    81

    adding a header file in VC 6.0

    Hello everyone

    Could anyone tell me how I can add a user defined header file in Visual C++ 6.0? The file I am trying to add contains a class and for the life of me I have tried everything, looked through this board, looked at the books I have, and I just can't seem to find the answer.

    I have tried to just run the file with the header file in the same directory, but it keeps giving me the LNK2001 unresolved external symbol error.

    Any suggestions would be very much appreciated.

  2. #2
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343
    This adds a header file.
    Code:
    #include "myfile.h"
    Make sure that the implementation and interface to the class is is in the right file (header and source).

    It would be easier to help you if you posted some code.

  3. #3
    Seeking motivation... endo's Avatar
    Join Date
    May 2002
    Posts
    537
    You can open the file, then right-click on the page and select "add file to project", and the header will be added and the relevant code compiled.
    Couldn't think of anything interesting, cool or funny - sorry.

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    81
    The #include "dice.h" was never the problem. It was always added to the code. But thanks for your time anyway!

    I have added it to the project, and yet I keep getting the following errors:

    Cpp1.obj : error LNK2001: unresolved external symbol "public: int __thiscall Dice::NumRolls(void)const " (?NumRolls@Dice@@QBEHXZ)
    Cpp1.obj : error LNK2001: unresolved external symbol "public: int __thiscall Dice::Roll(void)" (?Roll@Dice@@QAEHXZ)
    Cpp1.obj : error LNK2001: unresolved external symbol "public: int __thiscall Dice::NumSides(void)const " (?NumSides@Dice@@QBEHXZ)
    Cpp1.obj : error LNK2001: unresolved external symbol "public: __thiscall Dice:ice(int)" (??0Dice@@QAE@H@Z)


    I know it is just a linking problem as it's the same code as in the book I am working from. I've been trying to figure this out for 2 days now and I really don't know what to do anymore.

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    81
    Thanks SALEM that was indeed the problem.

    You guys are just great, thanks for all the responses!! They are always very much appreciated!!
    "Our greatest glory consists not in never failing,
    but in rising every time we fall."

    Oliver Goldsmith (1730-1774).
    Anglo-Irish writer, poet and playwright.

  6. #6
    Registered User
    Join Date
    Oct 2002
    Posts
    26
    hi you saying that you still getting the LNK2001 error and you

    saying that you put in the file for example ".h" you will get still

    that error if you don't add the header file at your project but for

    the best result is that every time you compile your project you

    have to make sure that at the class view you have the file in

    there so if you don't have the file in there just go at the top

    project and add a file that you wont this will help you a lot it

    helped me to ok just fallow this things
    <hr>
    &nbsp&nbsp&nbsp&nbsp&nbsp#include "header.h" exaple
    <hr>
    C++ Is cool

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie homework help
    By fossage in forum C Programming
    Replies: 3
    Last Post: 04-30-2009, 04:27 PM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  3. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM