- 博客(6)
- 收藏
- 关注
原创 C++字符串3——存取赋值
1.存取 reference operator[] (size_type pos); const_reference operator[] (size_type pos) const; reference at (size_type n); const_reference at (size_type n) const; basic_string substr(size_type pos =
2015-11-02 22:18:23 304
原创 C++字符串2——字符串构造
string类的构造函数: 1、string(const char* s); 2、string(size_type n, char c); 3、string(const string & str); 4、string(); 5、string(const char * s , size_type n); 6、template string(I
2015-10-31 23:17:27 535
原创 C++字符串1
一、C风格字符串 简略介绍一下,c风格字符串存储在字符串数组中,特别注意最后一个元素为空字符,否则就成了char类型的数组了。 字符串输入用cin,但是字符串中存在空格的时候就有缺陷。因此,使用istream类中的成员函数getlin()和get(); 1.getline()函数: getline()函数每次读取一行,它通过换行符来确定
2015-10-27 22:26:13 305
原创 运算符重载
一、操作符重载 用复数来实例:#include <iostream>using namespace std;class Complex {public: Complex (int r = 0, int i = 0) :m_r (r), m_i (i) {} Complex const operator+ (Complex const& rhs) const {
2015-10-26 23:38:11 233
转载 c++重载<, +, +=, =, ==, <<, >>等符号
以下示例中定义了一个class test,重载了>等符号:#include#includeusing namespace std;class test{public: int v; test():v(0){} test(const int &a):v(a){} test(const test &t1):v(t1.v){}
2015-10-25 22:39:18 447
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人