-
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? :confused:
__________________
-
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...
-
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?
-
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;
-
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?
-
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.
-
Thanks. I'll try that and get back to you...