Observer模式——行为模式 observer.h#ifndef _OBSERVER_H_ #define _OBSERVER_H_ #include <string> using namespace std; typedef string State; class Subject; class Observer { public: virtual ~Observer(); virtual void Update(Subject* sub) = 0; vir
linux下C语言操作mysql数据库(系统自带版本3.23.54) 我的上一篇blog介绍了在linux环境下如何安装配置系统自带的mysql数据库,并列举了mysql的一些简单的操作。接下来我将介绍一下如何利用mysql提供给我们的API来访问并操作mysql数据库(C语言)。首先,我们需要安装mysql-devel-3.23.54a-11.i386.rpm包,这样我们才能使用mysql提供的API和类库。mysql-devel-3.23.54a-11.i386.rpm的下载地址:http://www.rpmfind.net/linux/rpm2html/se
redhat9安装配置mysql数据库(系统自带,版本3.23.54) Mysql安装:首先,查看你的系统中是否已经安装了mysql,在终端里输入mysql,[root@localhost root]#mysqlbash: mysql: command not found说明系统中还没有安装mysql数据库,如果出现,说明已经安装了mysql数据库,那么跳过接下来的安装步骤,直接看配置步骤吧。“从这里开始”——>“系统设置”——>“添加/删除应用软件”——>“SQL数据库服务器”,如下图所示。选择——>“细节”,安装“标准软件包”和“额外软件包”,系统会提示你插入第二张和第三张
Flyweight模式——结构型模式 flyweight.h#ifndef _FLY_WEIGHT_H_ #define _FLY_WEIGHT_H_ #include <string> using namespace std; class Flyweight { protected: Flyweight(string intrinsic_state); public: virtual void Operation(const string& extrinsic_s
Strategy模式——行为模式 strategy.h#ifndef _STRATEGY_H_ #define _STRATEGY_H_ class Strategy { public: virtual ~Strategy(); virtual void AlgrithmInterface()=0; protected: Strategy(); }; class ConcreteStrategyA:public Strategy { public:
Template模式——行为模式 template.h#ifndef _TEMPLATE_H_ #define _TEMPLATE_H_ class AbstractClass { public: virtual ~AbstractClass(); void TemplateMethod(); protected: AbstractClass(); virtual void PrimitiveOperation1()=0; virtual void PrimitiveOp
Proxy模式——结构性模式 proxy.h#ifndef _PROXY_H_ #define _PROXY_H_ class Subject { public: virtual ~Subject(); virtual void Request()=0; protected: Subject(); }; class ConcreteSubject:public Subject { public: ConcreteSubject(); ~Con
Facade模式——结构型模式 外部与一个子系统的通信必须通过一个统一的门面(Facade)对象进行,这就是门面模式。facade.h#ifndef _FACADE_H_ #define _FACADE_H_ class SubSystem1; class SubSystem2; class Facade { public: ~Facade(); static Facade* Instance(); void OperationWrapper(); protected: Facade(); priv
Adapter模式——结构型模式 adapter.h#ifndef _ADAPTER_H_ #define _ADAPTER_H_ class Target { public: Target(); virtual ~Target(); virtual void Request(); }; class Adaptee { public: Adaptee(); ~Adaptee(); void SpecificRequest(); }; c
Bridge模式——结构型模式 tank.h#ifndef _TANK_H_ #define _TANK_H_ class TankImpl; class Tank { public: virtual ~Tank(); virtual void shot()=0; virtual void run()=0; protected: Tank(); }; class ChinaTank:public Tank { public: ChinaT
Bridge模式——结构型模式 tank.h#ifndef _TANK_H_ #define _TANK_H_ class TankImpl; class Tank { public: virtual ~Tank(); virtual void shot()=0; virtual void run()=0; protected: Tank(); }; class ChinaTank:public Tank { public: ChinaT
Singleton模式——创建型模式 Singleton.h#ifndef _SINGLETON_H_ #define _SINGLETON_H_ class Singleton { public: virtual ~Singleton(); static Singleton* Instance(); protected: Singleton(); private: static Singleton* m_instance; }; #endif
AbstractFactory模式——创建型模式 factory.h#ifndef _ABSTRACT_FACTORY_H_ #define _ABSTRACT_FACTORY_H_ class Product; class AbstractFactory { protected: AbstractFactory(); public: virtual ~AbstractFactory()=0; virtual Product* CreateProductA()=0; virtual P
FactoryPattern——创建型模式 以下代码已经在VC6.0中测试运行通过。factory.h#ifndef _FACTORY_H_ #define _FACTORY_H_ #include <string> using namespace std; class Fruit; class Factory { protected: Factory(){}; public: virtual ~Factory() = 0; virtual Fruit* Crea
像一个电脑高手一样操作windows——windows常用快捷键大全 一、常见用法:F1 显示当前程序或者windows的帮助内容。F2 当你选中一个文件的话,这意味着“重命名”F3 当你在桌面上的时候是打开“查找:所有文件” 对话框F10或ALT 激活当前程序的菜单栏windows键或CTRL+ESC 打开开始菜单CTRL+ALT+DELETE 在win9x中打开关闭程序对话框DELETE
细谈C/C++中的前置++和后置++ ++运算符是大家都再熟悉不过的东西了,无论是在for循环里,还是在一些赋值语句中,都有++的身影。这里我和大家分享一下我对++的理解,若有不足之处欢迎批评指正啊。首先,看这样一段代码:#include using namespace std; int main() { int i; ++++i; // All Right //i++++; // error C2105: '++' needs l-value //++i=10; // All Right
如果你的电脑蓝屏了,请温柔的对她。。。 如果你的电脑蓝屏了,请不要气愤的说一句"fucking shit,damn it“,然后直接冷启动。你可以根据屏幕上显示的错误码来判断是哪出了问题,下面就是一些蓝屏的原因,仅供参考。 0 0x00000000 作业完成。 1 0x00000001 不正确的函数。 2 0x00000002 系统找不到指定的档案。 3 0x00000003 系统找不到指定的路径。 4 0x00000004 系统无法开启档案。 5 0
windows下DLL的编写 在VC中新建一个空的Win32动态链接库工程(Win32 Domanic-Link Library),然后添加一个C++ Sourse File到工程,我这里的文件名取DllTest.cpp。然后在文件中添加如下内容: //DllTest.cpp _declspec(dllexport) int add(int a,int b) { return a+b; } _declspec(dllexport) int subtract(int
linux库文件编写 静态库与动态库的区别: 如果程序是在编译时加载库文件的,就是使用了静态库。如果是在运行时加载目标代码,就成为动态库。换句话说,如果是使用静态库,则静态库代码在编译时就拷贝到了程序的代码段,程序的体积会膨胀。如果使用动态库,则程序中只保留库文件的名字和函数名,在运行时去查找库文件和函数体,程序的体积基本变化不大。静态库的原则是“以空间换时间”,增加程序体积,减少运行时间;动态库则是“以时间换空间”,增加了运行时间,但减少了程序本身的体积。其实,程序设计就是一个“时间与空间的矛盾”。下面我们就以实际例