由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 一个c++小问题
相关主题
C++一个string的小问题问个overloading new operator的问题
问个c++的template的问题sizeof(string)
compile errorquestion overloading ++ error
member and friend请问关于overloading <<
make 时候遇到 undefined reference 怎么办?one question about overloading operator delete
为啥gcc找不到类的构造函数?why copy assignment operator returns non-const type?
string operator +ambiguous operators in c++
why use static function here?请教boost::any compile错误。
相关话题的讨论汇总
话题: string话题: operator话题: class话题: const话题: s1
进入Programming版参与讨论
1 (共1页)
H*M
发帖数: 1268
1
std::string s1;
/*...*/
if("string literal" == s1)
std::cout<<"equal"< 问这个==,compiler是怎么interpret的?global的operator,还是string class的member
function啊?
谢谢.
X****r
发帖数: 3557
2
bool operator== ( const char* lhs, const string& rhs );
H*M
发帖数: 1268
3
thanks.
how if it is:
if(s1 == "string literal")
it will be a member function of string class? which goes first?

【在 X****r 的大作中提到】
: bool operator== ( const char* lhs, const string& rhs );
X****r
发帖数: 3557
4
In the particular of of std::string, it is
bool operator== ( const string& lhs, const char* rhs );
More precisely, the standard prototype is
template
bool operator==(const basic_string& lhs,
const charT* rhs);
Generally, the member function of the class is used first as an
overloaded operator, then non-member function.

【在 H*M 的大作中提到】
: thanks.
: how if it is:
: if(s1 == "string literal")
: it will be a member function of string class? which goes first?

m********0
发帖数: 2717
5
Right.
http://www.mitbbs.com/article0/Quant/31216111_0.html

【在 X****r 的大作中提到】
: In the particular of of std::string, it is
: bool operator== ( const string& lhs, const char* rhs );
: More precisely, the standard prototype is
: template
: bool operator==(const basic_string& lhs,
: const charT* rhs);
: Generally, the member function of the class is used first as an
: overloaded operator, then non-member function.

1 (共1页)
进入Programming版参与讨论
相关主题
请教boost::any compile错误。make 时候遇到 undefined reference 怎么办?
c++ private 问题为啥gcc找不到类的构造函数?
用STL map的时候怎么自己定义大小比较的关系string operator +
C++ template questionwhy use static function here?
C++一个string的小问题问个overloading new operator的问题
问个c++的template的问题sizeof(string)
compile errorquestion overloading ++ error
member and friend请问关于overloading <<
相关话题的讨论汇总
话题: string话题: operator话题: class话题: const话题: s1