Trying to track down a LNK2019 Unresolved External Symbol error on a function that has a number of std::string const &
arguments.
Step one of this answer says to check decorated / undecorated names, an开发者_如何转开发d this is what I'm seeing in the linker error text in the argument list:
class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &
Is this also std::string const &
?
Thanks for your help.
I'm running VS 2008.
Yes.
As part of the C++ standardization, the std::string
class was made more STL-compatible. Like the STL containers, the element type can be chosen. Common choices are char
and wchar_t
, but Visual C++ users can also use TCHAR
. Like STL containers, memory allocation is handled by an allocator.
However, strings are unlike other containers because some methods need to perform more complex operations on their elements. std::set<T>
only needs to compare two T
objects, but std::string
needs to deal with multi-byte encodings and such complications. These details are wrapped up in class std::char_traits<char>
.
So, with all this complexity, you end up with std::basic_string<char, std::char_traits<char>, std::allocator<char> >
. That's of course not very friendly, and most people just need the defaults. std::string
is the friendly name for that.
精彩评论