构造函数(Constructors)
来源:互联网 发布:mac下什么浏览器好用 编辑:程序博客网 时间:2024/06/10 11:18
构造函数(Constructors)
语法:string(); string( size_type length, char ch ); string( const char *str ); string( const char *str, size_type length ); string( string &str, size_type index, size_type length ); string( input_iterator start, input_iterator end ); |
字符串的构造函数创建一个新字符串,包括:
- 以length为长度的ch的拷贝(即length个ch)
- 以str为初值 (长度任意),
- 以index为索引开始的子串,长度为length, 或者
- 以从start到end的元素为初值.
string str1( 5, 'c' ); string str2( "Now is the time..." ); string str3( str2, 11, 4 ); cout << str1 << endl; cout << str2 << endl; cout << str3 << endl;
显示
ccccc Now is the time... time
- 构造函数(Constructors)
- 构造函数(Constructors)
- Explicit Constructors(显式构造函数)
- Explicit Constructors(显式构造函数)
- Explicit Constructors(显式构造函数)
- Explicit Constructors(显式构造函数)
- Explicit Constructors(显式构造函数)
- Explicit Constructors(显式构造函数)
- Explicit Constructors(显式构造函数)
- C++ Explicit Constructors(显式构造函数)
- CPP-Calling constructors(调用构造函数)
- Explicit Constructors(显式构造函数)收藏
- STL库容器vector Constructors构造函数
- explicit Constructors——显式构造函数
- CRITICAL SKILL 9.1: Overloading Constructors 构造函数的重载
- C++11 FAQ中文版:委托构造函数(Delegating constructors)
- C++11 FAQ中文版:委托构造函数(Delegating constructors)
- 类的构造函数和析构函数 Class Constructors and Destructors
- ProxyFactoryBean属性介绍
- The best way to fix a bug
- bnu1272 Plural C语言版
- C#对于文件操作
- 2008中国十佳IC设计公司(四):Idea vs 人才
- 构造函数(Constructors)
- bnu1273 素素的困惑 C语言版
- 操作符(Operators)
- 添加文本(append)
- 赋值(assign)
- bnu1274 爱写注释的学生 C语言版
- 买的两本书今天终于收到了,真的是“巨”著啊,厚达1500多页!!
- at
- begin