2013年8月23日
摘要: 此类RESTful接口的开放平台,一般而言都采用OAuth认证方式针对新浪微博新版接口举例如下:1、获取codehttps://api.weibo.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&response_type=code&redirect_uri=YOUR_REGISTERED_REDIRECT_URI在创建应用时需要填写YOUR_REGISTERED_REDIRECT_URI,YOUR_CLIENT_ID即是App Keyhttps://api.weibo.com/oauth2/authorize?client_id=2 阅读全文
posted @ 2013-08-23 22:20 晴朗蝈蝈 阅读(435) 评论(0) 推荐(0) 编辑
2013年8月18日
摘要: #include templateclass disj_set {public: disj_set(){ for (int i=0; i rank[y]) father[fy] = fx; else { father[fx] = fy; if (rank[fx] == rank[fy]) rank[fy]++; } }private: int father[size]; int rank[size];};int main() { ... 阅读全文
posted @ 2013-08-18 10:57 晴朗蝈蝈 阅读(123) 评论(0) 推荐(0) 编辑
2012年8月25日
摘要: #include <iostream>using namespace std;#define REQUEST1 1#define REQUEST2 2#define REQUEST3 3/* *********************************************************************** * 职责链模式 * 将请求传递到可以处理的类为止,子类中包含着处理的下一个对象指针 * 默认处理程序终结处理 * 在每个处理类中判定请求是不是可以处理,并且可以做一次预处理 * ************************************* 阅读全文
posted @ 2012-08-25 20:43 晴朗蝈蝈 阅读(167) 评论(0) 推荐(0) 编辑
2012年8月20日
摘要: #include <iostream>using namespace std;class Singleton {private: Singleton() { } ~Singleton() { } static Singleton* pSingleton;public: static Singleton* GetInstance() { if (pSingleton == NULL) { pSingleton = new Singleton(); } return pSingleton; }};... 阅读全文
posted @ 2012-08-20 19:09 晴朗蝈蝈 阅读(70) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>using namespace std;/* 适配器模式:在复用已有代码出现接口不匹配的时候使用 适配器实际上是一个继承自目标接口的类,包含有一个以 往的接口,通过在重载方法中调用原来接口,来实现适配*///目标接口,适配器类继承此接口class Target {public: virtual void Request() { cout<<"普通请求"<<endl; }};//原有接口,需要包装在适配器类的接口中class Adaptee {public: void SpecificRequest() 阅读全文
posted @ 2012-08-20 16:32 晴朗蝈蝈 阅读(112) 评论(0) 推荐(0) 编辑
2012年8月10日
摘要: #include <iostream>#include <list>using namespace std;/* 观察者模式,当一个对象的改变需要同时改变其他对象,并且不知道有多少对象需要改变 主要工作在于解除耦合,让双方都依赖于抽象,而不是依赖于具体,使得各自的变化都不 会影响另一边的变化*/class Observer {public: virtual void Update() = 0;};class Subject {private: list<Observer*> m_pObservers;public: void Attach(Observer* 阅读全文
posted @ 2012-08-10 10:38 晴朗蝈蝈 阅读(112) 评论(0) 推荐(0) 编辑
2012年8月8日
摘要: #include <iostream>using namespace std;/* 为一组子类提供一个高层一致接口,使得这一组子列更加容易被使用 1、设计之初有意识将不同的层次分离,定义合适的外观接口 2、增加外观可以接口,减少依赖 3、维护遗留大型系统*/class SubOne {public: void Method() { cout<<"1"<<endl; }};class SubTwo {public: void Method() { cout<<"2"<<endl; }};class 阅读全文
posted @ 2012-08-08 15:53 晴朗蝈蝈 阅读(109) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>using namespace std;/* 模版方法模式是将不变的行为移动到父类中,去除子类中的重复代码 定义一个操作中的算法骨架,而将一些步骤延迟实现在子类中,这种 模式使得可以在不改变算法的结构下即可重定义算法的特定步骤*/class AbstractClass {public: virtual void PrimitiveOperation1() = 0; virtual void PrimitiveOperation2() = 0; void TemplateMethod() { PrimitiveOp... 阅读全文
posted @ 2012-08-08 15:50 晴朗蝈蝈 阅读(188) 评论(0) 推荐(0) 编辑
2012年8月5日
摘要: #include <iostream>using namespace std;/* 装饰模式是为已有功能动态添加更多功能的方法 装饰类和组件类的关系,装饰类为组件类添加功能,组件类 是装饰类的一个成员。这样可以在程序运行时动态的增删功 能,但是每一个装饰类不方便单独调试 使用装饰模式,可以达到串行化处理的效果*/class Component {public: virtual void Show() = 0;};class ConcreteComponent : public Component {public: void Show() { cout<<"C. 阅读全文
posted @ 2012-08-05 11:07 晴朗蝈蝈 阅读(112) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>using namespace std;/* 装饰模式是为已有功能动态添加更多功能的方法 装饰类和组件类的关系,装饰类为组件类添加功能,组件类 是装饰类的一个成员。这样可以在程序运行时动态的增删功 能,但是每一个装饰类不方便单独调试 使用装饰模式,可以达到串行化处理的效果*/class Component {public: virtual void Show() = 0;};class ConcreteComponent : public Component {public: void Show() { cout<<"C. 阅读全文
posted @ 2012-08-05 10:34 晴朗蝈蝈 阅读(124) 评论(0) 推荐(0) 编辑