C++ string类的问题
今天看书时碰到string类,于是想搞清楚它具体有哪些构造函数,看了一下有17个,其中有些用过了知道是什么意思了,还有些没用过想看看各个参数都是什么,没看懂,特别是用到typedef别名时,更是不懂了,比如
typedef typename _Alloc::template rebind<_Elem>::other _Alty;这个具体是什么意思,谁替代谁啊,哪里有比较全的typedef的文档说明,和string类的文档说明,大家都是这么学习string类的?
typedef A B ;
意思就是用B 替代A
#include <iostream>
#include <string>
typedef std::string temp ; //temp就代表了string类型
int main()
{
temp show("example") ;//等于 string show ("example") ;
std::cout << show ;
}
像我这么长的替换中间不止两个空格的 ,两个空格的话是这样的 typedef A B ;用B替换A
我这种情况,怎么分清楚那个是A 那个是B呢?
#include <iostream>
#include <string>
typedef std::string temp ; //temp就代表了string类型
int main()
{
temp show("example") ;//等于 string show ("example") ;
std::cout << show ;
}
http://www.cplusplus.com/reference/string/string/
这个是C++标准库的文档。
看到这样一个构造函数
string (string&& str) noexcept;
move constructorAcquires the contents of str.
str is left in an unspecified but valid state. 什么意思呢?