代码改变世界

STL list

2011-08-11 17:03 by Daniel Zheng, 371 阅读, 1 推荐, 收藏, 编辑
摘要:The standard template library supplies the programmer with a doubly linked list in the form of template class std::list.STL's list class allows for constant time insertions at the front, back, or middle of the sequence.Basic list OperationsBefore use it, you need to include the header file <l 阅读全文

STL Dynamic Array Classes

2011-08-11 01:26 by Daniel Zheng, 365 阅读, 0 推荐, 收藏, 编辑
摘要:Dynamic arrays supply the programmer with the flexibility of storing data without needing to know the exact volume thereof at the time of programming the application, the way static arrays do. Naturally, this is a frequently needed requirement and the STL supplies a ready-to-use solution in the form 阅读全文

The STL string Class

2011-08-11 00:49 by Daniel Zheng, 359 阅读, 0 推荐, 收藏, 编辑
摘要:The STL string class std::string helps you in the following ways:Reduces the effort of creation and manipulating stringsIncreases the stability of the application being programmed by internally managing memory allocation detailsSupplies copy constructor and assignment operators that automatically en 阅读全文

An Introduction to the Standard Template Library

2011-08-10 15:23 by Daniel Zheng, 236 阅读, 0 推荐, 收藏, 编辑
摘要:STL consist of three components:Container for storing informationIterators for accessing the information storedAlgorithms for manipulating the content of the containersSTL ContainersContainers are STL classes that are used to store data. There are two types of container classes:Sequential containers 阅读全文

Linux正则表达式--基础正则表示法

2011-08-09 23:00 by Daniel Zheng, 1880 阅读, 0 推荐, 收藏, 编辑
摘要:基础正规表示法(出自鸟哥的LINUX私房菜) 既然正规表示法是处理字符串的一个标准表示方式,他需要支持的工具程序来辅助, 所以,我们这里就先介绍一个最简单的字符串撷取功能的工具程序,那就是 grep 啰! 在介绍完 grep 的基本功能之后,就进入正规表示法的特殊字符的处理能力了。 [root@test root]# grep [-acinv] '搜寻字符串' filename参数说明:-a :将 binary 档案以 text 档案的方式搜寻数据-c :计算找到 '搜寻字符串' 的次数-i :忽略大小写的不同,所以大小写视为相同-n :顺便输出行号-v :反向 阅读全文

Makefile中的常用变量与函数

2011-08-09 15:59 by Daniel Zheng, 1909 阅读, 1 推荐, 收藏, 编辑
摘要:Makefile中的预定义变量:CC,C语言编译器的名称,ccCPP, C语言预处理器的名称,$(CC) -ECXX, C++语言的编译器名称,g++RM,删除文件程序的名称,rm -fCFLAGS, C语言编译器的编译选项,无默认值CPPFLAGS,C语言预处理器的编译选项,无默认值CXXFLAGS,C++语言编译器的编译选项,无默认值注:在使用RM时,一般使用如下语句: -$(RM) $(TARGET) $(OBJS), 符号“-”表示在操作失败时不报错,而是继续执行。例如在不存在TARGET时将继续删除OBJS。Makefile中的自动变量:$*, 表示目标文件的名称,不包含扩展名$@, 阅读全文

Effective C++ 学习笔记(27)

2011-08-09 11:38 by Daniel Zheng, 260 阅读, 0 推荐, 收藏, 编辑
摘要:弄清C++在幕后为你所写,所调用的函数 一个空类什么时候不是空类?---- 当C++编译器通过它的时候。如果你没有什么下列函数,那么编译器会自动声明它自己的版本。这些函数就是:一个拷贝构造函数,一个赋值运算符,一个析构函数,一对取址运算符。如果你没有声明如何构造函数,那么它也会为你声明一个缺省构造函数。所以这些函数都是public。class Empty {}; 和下面是一样的:class Empty{public: Empty(); Empty(const Empty & rhs); ~Empty(); Empty & operator=(const Empty & 阅读全文

Effective C++ 学习笔记(26)

2011-08-07 18:27 by Daniel Zheng, 184 阅读, 0 推荐, 收藏, 编辑
摘要:说你想说的;理解你所说的 在本章关于 "继承和面向对象设计" 的简介中,我曾强调,理解不同的面向对象构件在C++中的含义十分重要。这和仅仅知道C++语言的规则有很大的不同。例如,C++规则说,如果类D 从类B 公有继承,从D 的指针到B 的指针就有一个标准转换;B 的公有成员函数将被继承为D 的公有成员函数,等等。这些规则都是正确的,但在将设计思想转化为C++的过程中,它们起不到任何作用。相反,你需要知道,公有继承意味着 "是一个",如果D 从B 公有继承,类型D 的每一个对象也 "是一个" 类型B 的对象。因而,如果想在设计中表示 阅读全文

Effective C++ 学习笔记(25)

2011-08-07 18:14 by Daniel Zheng, 354 阅读, 0 推荐, 收藏, 编辑
摘要:明智的使用私有继承 C++将公有继承视为 "是一个" 的关系。例如:某个类层次结构中,Student 类从Person 类公有继承,为了使某个函数成功调用,编译器可以在必要时隐式地将Student 转换为Person。这个例子很值得再看一遍,只是现在,公有继承换成了私有继承: class Person { ... };class Student:private Person { ... }; // 使用私有继承void dance(const Person& p); // 每个人会跳舞void study(const Student& s); // 只有学生 阅读全文

Effective C++ 学习笔记(24)

2011-08-07 17:52 by Daniel Zheng, 234 阅读, 0 推荐, 收藏, 编辑
摘要:通过分层来体现“有一个”或“用...来实现” 使某个类的对象成为另一个类的数据成员,从而实现将一个类构筑在另一个类之上,这一过程称之为“分层”。例如: class Address {...};class PhoneNumber {...};class Person{public: ...private: string name; Address address; PhoneNumber voiceNumber; PhoneNumber faxNumber;}; 本例中,Person 类被认为是置于string,Address 和PhoneNumber 类的上层,因为它包含那些类型的数据成员。& 阅读全文