C 字符串:: NPO是在调用字符串类
c++ string :: npos is it calling the string class?
我是C 的新手,从Java移动并想知道:
pos = result.find(remove[i]);
if (pos == string::npos)
它将字符串称为"超类"?如果我在调用类本身来访问常数的" npos",我很困惑它如何知道我的函数中有几个字符串变量的类别?
npos
不绑定到一个实例,而是与类本身绑定。这是static
成员。Java中也有static
成员。
21.4类模板basic_string [basic.String]
[...]
namespace std {
template<class charT, class traits = char_traits<charT>,
class Allocator = allocator<charT> >
class basic_string {
public:
//...
static const size_type npos = -1;
//...
};
std::string
是 basic_string
的专业
npos
是字符串的静态成员。
C 中的静态成员每个程序都创建一次,并由同一类的所有实例共享。但也可以在不进行班级的情况下访问。
相关文章:
- 调用CreateProcess()并获取字符串的返回值
- Visual c ++,使用字符串引用/指针调用 dll 函数
- 接收字符串并使用它来调用方法C++
- 如果结构中的字符串比使用的 p/调用签名长或短,会发生什么情况?
- 在字符串函数中抛出'char const*'实例后调用的终止
- 如何将字符串从 C++/CLI 方法返回到调用它的非托管C++
- 为什么在调用C#DLL时不需要提供字符串缓冲区
- 没有使用两种类型的字符串进行匹配的函数调用
- 添加字符串类型的类成员会导致调用基类函数而不是子函数
- C++ 通过字符串调用类中的成员
- 如何将字符串调用到引号中
- 使用QString或字符串调用结构对象
- C++按字符串调用函数,比较PHP的性能,如何在C++中优化代码
- 使用字符串调用方法时出错:类型为'size_t和
- 外部字符串调用导致32位的Segfault,以64位工作
- 使用变量参数映射函数并通过字符串 c++ 调用
- 使用包含函数名称的字符串调用函数
- C++-将输入函数作为字符串调用
- 如果使用错误的格式字符串调用 printf,会发生什么情况
- c++从字符串调用方法