【发布时间】:2011-10-10 10:39:28
【问题描述】:
vector<string> MyStrings;
vector<string>::iterator ItStr;
我正在使用c_str() 来返回指向字符串的指针。
为什么需要用括号取消引用?
无法编译:*ItStr.c_str();
错误 C2039: 'c_str' : 不是 'std::vector<_ty>::iterator' 的成员
编译/使用迭代器周围的括号:(*ItStr).c_str();
如果您能指出我(不是双关语)正确的方向,我将不胜感激。谢谢!
【问题讨论】:
-
(和)通常称为括号; brackets 通常指的是[和](而{和}通常指的是moustaches;呃,我的意思是braces)。 -
用“括号”修复了问题