What's the difference between String::size_type and int ?

gaowudi 2003-04-20 08:37:25
Thanks a lot.
...全文
68 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
fullsail 2003-04-27
  • 打赏
  • 举报
回复
String::size_type ?
你说的是MFC的CString还是std::string.
如果是前者就是unsigned int,
如果是后者,他是一个类型,根据不同编译器的实现,有不同的实作版本,就看你的编译器是如果实现STL,你大部分使用的应该是size_t
linchwu 2003-04-20
  • 打赏
  • 举报
回复
up

string::npos 到底指的哪儿?
point_to 2003-04-20
  • 打赏
  • 举报
回复
辛苦了!!
lifanxi 2003-04-20
  • 打赏
  • 举报
回复
string里的size_type是这样来的:
typedef _A::size_type size_type;
_A::size_type是这样来的:
typedef _SIZT size_type;
_SIZT是这样来的
#define _SIZT size_t
size_t是这样来的:
typedef unsigned int size_t;
以上是在VC6中找到结果。


point_to 2003-04-20
  • 打赏
  • 举报
回复
The unsigned integer type describes an object that can represent the length of any controlled sequence. It is described here as a synonym for the unspecified type T0 (typically A::size_type).

String::size_type 有这个么?if,表示长度,是类string的一个成员

而int是一种类型!
lifanxi 2003-04-20
  • 打赏
  • 举报
回复
如果你在VC中最根溯源的话,你会发现size_type就是unsigend int
是一系列typedef的结果。

69,369

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧