- 博客(30)
- 资源 (1)
- 收藏
- 关注
翻译 C# 析构函数解析(译)
C# 析构函数解析(译) Chandra Hundigam2002-06-18原文地址:http://www.c-sharpcorner.com/UploadFile/chandrahundigam/UnderstandingDestructors11192005021208AM/UnderstandingDestructors.aspx 这篇文章谈了如何理解C#的析构
2012-04-24 23:07:49 2423 1
翻译 Google C++ 编程风格指南(中文翻译)-1
个人感觉总结的很好,正在试图翻译,待续...原文:http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml
2011-03-16 00:02:00 1387
转载 RTTI
RTTI(Run-Time Type Identification,通过运行时类型识别)程序能够使用基类的指针或引用来检查这些指针或引用所指的对象的实际派生类型。
2011-03-14 21:43:00 387
原创 STL_Algorithm: heap
只能用于数组,vector, dequestd::make_heap( v.begin(), v.end() ); //建堆std::sort_heap( v.begin(), v.end() ); //对堆进行排序std::push_heap( v.begin(), v.end() ); //在堆中加一新值std::pop_heap( v.begin(), v.end() - index ); //删除堆顶元素, 进行元素位置改变,pop出的值放入v.end() - index处,这样
2011-01-09 22:32:00 523
原创 STL_Algorithm: lower_bound, upper_bound, equal_range
std::lower_bound( v.begin(), v.end(), value ); // 第一个value的位置std::upper_bound( v.begin(), v.end(), value ); //最后一个vlaue的位置std::pair iterator, std::vector iterator > eq_range = std::equal_range( v.begin(), v.end(), value ); //value的第一个和最后位置
2011-01-09 21:29:00 963
原创 STL_Algorithm10: Set--集合操作
std::includes( a1, a1 + SIZE1, a2, a2 + SIZE2 ); //包含关系,a1是否包含a2.std::set_difference( a1, a1 + SIZE1, a2, a2 + SIZE2, a3 ); //a1中不在a2中的元素std::set_intersection( a1, a1 + SIZE1, a2, a2 + SIZE2,a3 ); //交集std::set_sysmmetric_difference( a1, a1 + SIZE, a2
2011-01-06 22:31:00 720
原创 STL_Algorithm9: inplace_merge, unique_copy, reverse_copy
std::inplace_merge( c1.begin(), c1.begin() + mid, c1.end() ); //把c1内部的两个有序段mergestd::unique_copy( c1.begin(), c1.end(), std::back_inserter( c2 ) ); //把c1的所有唯一元素copy到c2std::reverse_copy( c1.begin(), c1.end(), std::back_inserter( c2 ) ); //把c1的元素颠倒copy到c
2011-01-05 23:07:00 541
原创 STL_Algorithm8: copy_backward, merge, unique, reverse
std::copy_backward( c1.begin(), c1.end(), c2.end() ); //从后往前copystd::merge( c1.begin(), c1.end(), c2.begin(), c2.end(), c3.begin() ); //把两个升序容器(c1, c2)合并为另一升序容器c3;std::merge( c1.begin(), c1.end(), c2.begin(), c2.end(), std::back_insert( c3 ) );std::u
2011-01-05 22:31:00 435
原创 STL_Algorithm7: swap
std::swap( a[0], a[1] ); //交换数组中的两个值std::iter_swap( &a[0], &a[1] );std::ranges( a, a+5, a+5 );//交换两个范围内的值,可用于交换不同数组
2011-01-03 22:50:00 547
原创 STL_Algorithm6--find, find_if, sort, binary_search
std::find( v.begin(), v.end(), value );std::find_if( v.begin(), v.end(), greater10 );std::sort( v.begin(), v.end() ); //要求随机访问迭代器std::binary_search( v.begin(), v.end(), value );//已经按升序排列
2011-01-03 22:20:00 593 2
原创 STL_Algorithm5-math: random_shuffle, count, count_if, min_element, max_element, accumulate, for_each, transform
STL_Algorithm5-math: random_shuffle, count, count_if, min_element, max_element, accumulate, for_each, transformminrandom_shuffle: 对v.begin()到v.end()之间的元素进行随机排序。count: 统计v.begin()到v.end()之间值为value的元素个数。count_if: 统计v.begin()到v.end()之间,满足判定条件的元素个数。m
2010-12-25 12:09:00 440
原创 STL_Algorithm4: Replace, replace_if, replace copy, replace_copy_if
STL_Algorithm4: Replace, replace_if, replace copy, replace_copy_if
2010-12-25 11:41:00 574
原创 STL_Algorithm3: remove, remove_if, remove_copy, remove_copy_if
STL Algorithm3: remove, remove_if, remove_copy, remove_copy_if 的用法示例
2010-12-23 23:37:00 378
原创 STL_Algorithm2: equal, mismatch, lexicographical_compare
STL Algorithm2: equal, mismatch, lexicographical_compare 的示例用法
2010-12-23 23:33:00 335
原创 STL_Algorithm1: Fill, Fill_n, Generate, Generate_n
STL, Algorithm: fill, fill_n, generate, generate_n的例子程序
2010-12-23 23:25:00 355
原创 C++中的几种type cast
static_cast:无条件转换,强制隐式转换,implicit conversion, 例如:non const -> const, int -> doubledynamic_cast:有条件转换,进行执行期检验;安全向下转型(safe down casting)决定某对象是否属于继承体系中的某个类型。reinterpret_cst:低级转型,例如:pointer to int (int*) -> intconst_cast:将对象的常量性去掉(cast away the constness);
2010-12-12 12:18:00 872
原创 STL容器使用中的拷贝成本
STL, 序列化容器的在使用时隐藏的拷贝成本, vector是连续存储的,可理解成可变空间大小的数组,但灵活就要有成本.你会发现在前面insert一个对象的成本有多大,STL vector的实现有点让人匪夷所思。
2010-12-11 23:36:00 369
原创 Pass by reference 为什么更安全?
引用的规则: (1)引用被创建的同时必须被初始化(指针则可以在任何时候被初始化)。 (2)不能有NULL引用,引用必须与合法的存储单元关联(指针则可以是NULL)。 (3)一旦引用被初始化,就不能改变引用的关系(指针则可以随时改变所指的对象)。
2010-06-22 23:12:00 357
转载 重写(覆盖)与重载 Override and Overload
覆盖、重写与重载的理解 初次见到这两个单词并没有什么特别的感觉,但是时间长了,却发现书上一会儿用override,一会儿又用overload,搞得我的迷迷糊。于是就做了个总结,希望能对和我一样对这两个概念模糊不清的网友有一个帮助。 override可以翻译为覆盖,从字面就可以知道,它是覆盖了一个方法并且对其重写,以求达到不同的作用。对我们来说最熟悉的覆盖就是对接口方法的实现,在
2009-11-02 22:03:00 333
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人