Thread: Error message...

  1. #1
    Meganan
    Join Date
    Oct 2005
    Posts
    13

    Question Error message...

    Code:
    n_str.obj : error LNK2001: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall priority::getValPos(int)" (?getValPos@priority@@QAE?AV?$basic_string@DU?$char_traits@D
    @std@@V?$allocator@D@2@@std@@H@Z)
    Does anybody know what this error message is trying to tell me?

    __________________
    Intelligence is Knowledge, but Wisdom is Depth.
    Stupidity is overwhelming.

  2. #2
    Registered User
    Join Date
    May 2005
    Posts
    28
    Did you include <string>?
    And are you linking the correct LIB which contains it? I'm not sure which that is since I've never had this problem specifically with strings but this is the error when your linker can't locate the function...

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Actually, it looks like string priority::getValPos(int) isn't defined, or isn't being linked. Did you define that function? Is the cpp file you defined it in part of your project or makefile? Did you accidentally forget the priority:: in the definition?

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Code:
    #include <string>
    
    using namespace std;
    Make sure use default libraries is checked in your compiler options. If you do not want to use the using statement then use the scope resolution operator to access string.

    std::string MyString;

  5. #5
    Meganan
    Join Date
    Oct 2005
    Posts
    13
    I think it has to do with the fact that i'm trying to use template functions in my classes

    for e.g. template <class strr> strr getValPos(int);

    It was the change to templates that made the difference. I should have said that. Before templates i was just using the string class. Yes i have added the include file. I am using 6.0. I have already done what you have said above. sorry about the confusion. so can i do this?
    Intelligence is Knowledge, but Wisdom is Depth.
    Stupidity is overwhelming.

  6. #6
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    That template function should be defined (not just declared) in the header file. If it is defined in the cpp file it will cause that linker error.

  7. #7
    Meganan
    Join Date
    Oct 2005
    Posts
    13
    Thanks. I'll try that and get back to you...
    Intelligence is Knowledge, but Wisdom is Depth.
    Stupidity is overwhelming.

Popular pages Recent additions subscribe to a feed