posts - 11,comments - 13,trackbacks - 0
re: Bridge模式 Super- 2009-06-19 09:57
呵呵,对的哦,忘了写public继承了;
class CExtendAbstract:public CAbstract
另外将
CExtendAbstract* abstr = new CExtendAbstract(value);
修改为
CAbstract* abstr = new CExtendAbstract(value);
re: State设计模式 Super- 2009-06-18 23:51
#include <vector>
#include <iostream>
#include <algorithm>


typedef int (*MsgProc)();
typedef struct _SWITCH_CASE_
{
int m_value;
MsgProc m_proc;
_SWITCH_CASE_(int value,MsgProc proc)
{
m_value = value;
m_proc = proc;
}
_SWITCH_CASE_(int a)
{
m_value = a;
}

bool operator == (const int value)
{
return (value == m_value);
}

}SWITCHCASE;


std::vector<SWITCHCASE> g_vec;

int DealError()
{
std::cout<<"Deal Error!"<<std::endl;
return 1;
}

int DealSuccess()
{
std::cout<<"Deal Success!"<<std::endl;
return 0;
}



int main(int argc,char * argv[])
{
SWITCHCASE a(0x01,DealError);
SWITCHCASE b(0x00,DealSuccess);
g_vec.push_back(a);
g_vec.push_back(b);
while(1)
{
int a;
std::cin>>a;
int b = 0;

std::vector<SWITCHCASE>::iterator iter = find(g_vec.begin(),g_vec.end(),a);
if(iter != g_vec.end())
{
(*iter).m_proc();
}
else
{
break;
}
}

}
vc在release时,加入了迭代子检测;
程序可以强制修改_SECURE_SCL为0,就可以解决问题了;