1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Pls Help

Discussion in 'C' started by nutty boy, Apr 13, 2007.

  1. nutty boy

    nutty boy New Member

    Joined:
    Apr 9, 2007
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    Hi
    I'm using MS Visual Studio 2005 and have made a class called "Stack_Class" whiich consist of "class.cpp" and "class.h"
    when i made a c++ program and i want to use "stack_class" i added just a refrencs to the header file class.h
    like this
    #include <C:\Visual Studio 2005\Projects\stack\stack\Stack.h>
    in the main program file(.cpp)
    Then compiled my program it gives the following errors
    1>Main.obj:error LNK2019: unresolved external symbol "public: __thiscall Stack_Class::~Stack_Class(void)" (??1Stack_Class@@QAE@XZ) referenced in function _main
    1>Main.obj:error LNK2019: unresolved external symbol "public: int __thiscall Stack_Class::Pop_It(int *)" (?Pop_It@Stack_Class@@QAEHPAH@Z) referenced in function _main
    1>Main.obj:error LNK2019: unresolved external symbol "public: int __thiscall Stack_Class::Push_It(int)" (?Push_It@Stack_Class@@QAEHH@Z) referenced in function _main
    1>Main.obj:error LNK2019: unresolved external symbol "public: __thiscall Stack_Class::Stack_Class(unsigned char)" (??0Stack_Class@@QAE@E@Z) referenced in function _main
    1>C:\Visual Studio 2005\Projects\Test_Stack\Debug\Test_Stack.exe : fatal error LNK1120: 4 unresolved externals
    but when i added the"stack.cpp" to the main program file(.cpp)
    it works fine ---->Why
    when i'm use function like printf i only include the "stdio.h" without its associated .cpp file
    thanks
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    We don't know how your project is set up, but probably not like that. Put your .h file in the same directory as your source file and include it like this: #include "Stack.h". If you want it in a subdirectory for some reason, use #include "mysubdirectory/Stack.h". The brackets (<>) are used for files which are to be found on the include path you have specified in your settings.

    FURTHERMORE: if you haven't read the "Before you make a query" thread, please do that now. I don't want to say your subject title is stupid, but I'm strongly tempted to. How is the next visitor going to search for technical information if all the subjects say "Pls Help"?? I'm also of the opinion that a person who types 'pls' instead of 'please' belongs in a chat room instead of a programming forum, because programming requires accuracy and correct syntax.
     
  3. nutty boy

    nutty boy New Member

    Joined:
    Apr 9, 2007
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    Hi DaWei
    Thanks 4 ur reply and i want u to know that i'm newbie in c++ programming so i asked this Question also i promise that i will concern about ur advices
     

Share This Page