代码改变世界

阅读排行榜

构造函数与拷贝解析

2007-03-18 20:43 by ubunoon, 201 阅读, 收藏,
摘要: 当我们声明一个类的时候,可能会需要另外一个类的实体去初始化一个新定义的类。//类定义//此类只能实现数据的拷贝,而不能够对资源进行操作。classScreenOnlyCopyData...{public:shortheight()...{/**//*...*/}shortweight()...{/**//*...*/}stringscreen()...{/**//*...*/}private:string_screen;string::size_type_cursor;short_height,_weight;};//当有一个类对象实现时,ScreenOnlyCopyDatas1;//对s1进 阅读全文

Bridge模式

2008-04-20 10:07 by ubunoon, 200 阅读, 收藏,
摘要: Bridge模式可以更方便的扩展,实现了类的实现与定义的完全分离。实现方式为:通过定义两个类,一个类来定义功能,另一个类来实现功能,实现功能的类的对象以参数形式赋给定义功能的类,从而实现信息相互配合使用。本想在此处插入Bridge模式的UML图示,插入太麻烦,过几天修改插入!下面是Bridge模式的一个实现例子: /// 抽象类定义//window.h:interfaceforthewindowclass.///**///////////////////////////////////////////////////////////////////////#if!defined(AFX_WIN 阅读全文

c语言函数库

2004-12-27 14:53 by ubunoon, 196 阅读, 收藏,
摘要: http://blog.csdn.net/shaohui/archive/2004/11/05/167969.aspx 阅读全文

迭代器的使用方法简要介绍(摘自C++Primer)

2006-10-15 13:40 by ubunoon, 194 阅读, 收藏,
摘要: 代码主要显示了迭代器使用泛型算法#include <vecotor>#include <algorithm>#include <iostream>int ia[10] = {51,23,7,88,41,98,12,103,37,6};int main(){ vector < int > vec( ia, ia+10); // 排序数组 sort ( vec.begin(), vec.end() ): // 获取值 int search_value; cin >> search_value; // 搜索元素 vector < in 阅读全文

Thinking In C++笔记(一)

2008-04-09 17:23 by ubunoon, 190 阅读, 收藏,
摘要: Ifyoudon'tknowwhatexceptionsmightoccur,don'tuseexceptionspecification. Exceptionspecificationaremainlyfornon-templateclasses.Duetoyoudon'tknowwhatwilloccurwhentemplateclassconstructorthrowanexception,youprogramwouldterminate. Itisbettertoseperatetwoactionsintotowseperatememberfunction,wh 阅读全文