随笔分类 -  C++基础

string类的构造和析构
摘要:class String { public: String(const char * str); String(const String & other); ~String(); String& operator=(const String & other); private: char * m_d 阅读全文

posted @ 2017-02-06 20:44 tomcao 阅读(558) 评论(0) 推荐(0)

C++二维指针
摘要:二维指针的声明 int[5][10] int** p = (int**)new int*[5]; //定义5个指向int*的指针,每个指针是指向int*的指针 for(int i = 0; i < 5; ++i) { P[i] = new int[10]; } //对每个二维指针分配内存 二维指针的 阅读全文

posted @ 2017-02-06 20:18 tomcao 阅读(2632) 评论(0) 推荐(0)

删除map容器中指定的元素
摘要:for (std::map<Int64,Int64>::iterator iter = ips_forbidden_.begin(); iter != ips_forbidden_.end();) { if (cur_time >= iter->second) { ips_forbidden_.er 阅读全文

posted @ 2016-10-29 17:51 tomcao 阅读(4613) 评论(0) 推荐(0)

operator++()和operator++(int)的区别
摘要:// 前缀形式:增加然后取回值UPInt& UPInt::operator++(){ *this += 1; // 增加 return *this; // 取回值}// postfix form: fetch and incrementconst UPInt UPInt::operator++(in 阅读全文

posted @ 2016-10-29 17:46 tomcao 阅读(1023) 评论(0) 推荐(2)

正确使用stl map的erase方法
摘要:先声明:下面的文章是针对windows的用法,因为std::map的erase函数的windows的实现版本是返回一个std::map的迭代器,但是STL标准里面的该函数的返回值确是: map.erase有3个重载:void erase ( iterator position );size_type 阅读全文

posted @ 2016-10-29 17:43 tomcao 阅读(16008) 评论(0) 推荐(1)

导航