2014年4月21日

the “inner class” idiom

摘要: 有些时候我们需要upcast为多种类型,这种情况下除了可以使用multiply inherits还可以inner class。 以下为例子://: C10:InnerClassIdiom.cpp// Example of the "inner class" idiom.#include #inclu... 阅读全文

posted @ 2014-04-21 23:13 FlowingCloud 阅读(197) 评论(0) 推荐(0) 编辑

2014年4月16日

State 状态模式

摘要: 常见设计模式之状态模式青蛙王子的故事,青蛙王子在公主亲吻前后表现是不一样的,这里以打招呼为例。//: C10:KissingPrincess.cpp#include using namespace std;class Creature { bool isFrog;public: Creature... 阅读全文

posted @ 2014-04-16 22:46 FlowingCloud 阅读(192) 评论(0) 推荐(0) 编辑

2014年4月15日

Singleton 单例模式

摘要: 常见设计模式之单例模式//: C10:CuriousSingleton.cpp// Separates a class from its Singleton-ness (almost).#include using namespace std;template class Singleton { ... 阅读全文

posted @ 2014-04-15 22:22 FlowingCloud 阅读(183) 评论(0) 推荐(0) 编辑

2014年4月14日

virtual base classes

摘要: virtual base classes用来实现菱形继承解决多个重复subobject的问题//: C09:VirtualBase.cpp// Shows a shared subobject via a virtual base.#include using namespace std;class Top{protected: int x;public: Top(int n) { x = n; } virtual ~Top() {} friend ostream& operator(&b) (&b); cout (p) (p) <... 阅读全文

posted @ 2014-04-14 23:03 FlowingCloud 阅读(259) 评论(0) 推荐(0) 编辑

2014年4月13日

typeid操作符

摘要: typeid() operator返回type_info,返回值不可拷贝、不可赋值// Illustrates the typeid operator.#include #include using namespace std;struct PolyBase { virtual ~PolyBase() {} };struct PolyDer : PolyBase { PolyDer() {} };struct NonPolyBase {};struct NonPolyDer : NonPolyBase { NonPolyDer(int) {} };int main() { // Test p. 阅读全文

posted @ 2014-04-13 15:51 FlowingCloud 阅读(286) 评论(0) 推荐(0) 编辑

函数对象

摘要: 函数对象是类似于函数的对象,就是具有operator()的对象#include #include using namespace std;void test(int i){ cout void myfor_each(Iter begin, Iter end, UnarFunc fun){ while (begin != end) { fun(*begin); //fun.operator()(*begin); ++begin; }}int main(int argc, char* argv[]){ int a[5] = {0,... 阅读全文

posted @ 2014-04-13 15:24 FlowingCloud 阅读(172) 评论(0) 推荐(0) 编辑

2014年3月9日

初识makefile

摘要: make是常用的一个管理工程编译的工具其基本用法是:1、make,使用makefile作为规则文件2、make -f mf,使用mf作为makefile3、make all,make clean 指定目标4、make CPP=g++ 宏定义替换make的重点在makefile的内容0、基本格式# commenttarget: dependency rule若target时间比dependency早,则根据rule生成target注:rule前面是tab,不是空格1、简单的makefilehello.exe: hello.cpp g++ -o hello.exe hello.cpp2、宏 ... 阅读全文

posted @ 2014-03-09 16:11 FlowingCloud 阅读(256) 评论(0) 推荐(0) 编辑

2014年2月28日

postgresql 免安装版使用

摘要: 免安装版 postgresql 使用1、首先使用 initdb 初始化数据目录initdb --pgdata=data --encoding=UTF8 --locale=C2、启动postgres -D "data"pg_ctl -D "data" -l logfile.log startpg_ctl -D "data" -l logfile.log stop3、创建用户和角色createuser -P root 创建root用户4、访问使用pgAdmin3访问和管理数据库5、远程访问权限pg_hba.conf:在这里的最底下6、配置 阅读全文

posted @ 2014-02-28 21:41 FlowingCloud 阅读(1772) 评论(0) 推荐(0) 编辑

2014年2月12日

python备份mysql数据库

摘要: 介绍使用python结合mysqldump对mysql数据库进行备份import osimport sysimport configparserimport timedef test_file_path(fp): if not os.path.exists(fp): raise RuntimeError('file {} not found'.format(fp))def backup_mysqldb(backup_param): test_file_path(backup_param['mysql']['dump']) test_file_pa 阅读全文

posted @ 2014-02-12 22:26 FlowingCloud 阅读(626) 评论(0) 推荐(0) 编辑

python解析ini文件

摘要: python解析ini文件使用configparser — Configuration file parsersections() add_section(section) has_section(section)操作sectionoptions(section) has_option(section, option) 操作itemsread(filenames, encoding=None) read_file(f, source=None) read_string(string, source='') read_dict(dictionary, source='&# 阅读全文

posted @ 2014-02-12 22:15 FlowingCloud 阅读(602) 评论(0) 推荐(0) 编辑

导航