当前位置: 编程技术>综合
本页文章导读:
▪悲剧,具体把多态用在数组上 有码有真相:
#include <iostream>
#include <map>
#include <string>
#include <memory>
using namespace std;
class AbstractEvent
{
public:
virtual char* Event(char* apMsg)=0;
};
class AbstractMsgHandler
{
public:
virtual v.........
▪Android必问的面试题
Android项目的开发流程。Activity的启动模式有哪些,在项目中是如何应用的。Button,ImageButton,ImageView的区别是什么,平时项目中是如何使用的。如何管理Android的内存(工具),说一说在项目中.........
▪一个sql语句的基本用法 //xp创建指令
exec xp_cmdshell 'mkdir D:\\DB'
//如果系统存在此对象的数据库 删除
if exists(select * from sysdatabases where name = 'StuDB')
drop database StuDB
//创建数据库StuDB
//数据库名字,文件路径,文件大.........
[1]悲剧,具体把多态用在数组上
来源: 互联网 发布时间: 2013-11-10
有码有真相:
#include <iostream> #include <map> #include <string> #include <memory> using namespace std; class AbstractEvent { public: virtual char* Event(char* apMsg)=0; }; class AbstractMsgHandler { public: virtual void Handler(char* apAnswer)=0; }; class AbstractEventPool { public: virtual void Register(AbstractEvent* apAbstractEvent)=0; }; class MsgSender { public: MsgSender(AbstractEvent* apSubscribeEvent,AbstractMsgHandler* apMsgHandler): m_pSubscribeEvent(apSubscribeEvent),m_pMsgHandler(apMsgHandler) { } void SendMsg(char* apMsg) { char* lpAnswer = m_pSubscribeEvent->Event(apMsg); m_pMsgHandler->Handler(lpAnswer); } private: AbstractEvent* m_pSubscribeEvent; AbstractMsgHandler* m_pMsgHandler; }; class ConcreteEvent:public AbstractEvent { public: char* Event(char* apMsg) { return apMsg; } }; typedef map<int,AbstractEvent*> EventMap; class ConcreteEventPool:public AbstractEventPool { public: void Register(const int& aEventEnum,AbstractEvent* apAbstractEvent) { EventMap::iterator lIter = m_EventMap.find(aEventEnum); if (m_EventMap.end() != lIter) { m_EventMap.insert(std::make_pair(aEventEnum,apAbstractEvent)); } } private: EventMap m_EventMap; }; class ConcreteMsgHandler:public AbstractMsgHandler { void Handler(char* apAnswer) { std::cout << apAnswer << std::endl; } }; int main() { std::auto_ptr<AbstractEvent> lpAbstractEvent(new ConcreteEvent()); std::auto_ptr<AbstractMsgHandler> lpAbstractMsgHandler(new ConcreteMsgHandler()); std::auto_ptr<MsgSender> lpMsgSender(new MsgSender(lpAbstractEvent.get(),lpAbstractMsgHandler.get())); char* lpMsg = "Hello World!"; lpMsgSender->SendMsg(lpMsg); return 0; }
oh,no,我怎么相处这样的代码。。。。。。
作者:boyhailong 发表于2013-1-12 23:11:30 原文链接
阅读:0 评论:0 查看评论
[2]Android必问的面试题
来源: 互联网 发布时间: 2013-11-10
作者:zapzqc 发表于2013-1-12 23:11:04 原文链接
阅读:0 评论:0 查看评论
[3]一个sql语句的基本用法
来源: 互联网 发布时间: 2013-11-10
//xp创建指令
exec xp_cmdshell 'mkdir D:\\DB'
//如果系统存在此对象的数据库 删除
if exists(select * from sysdatabases where name = 'StuDB')
drop database StuDB
//创建数据库StuDB
//数据库名字,文件路径,文件大小,文件最大空间,增长速度
create database StuDB
on
(
name = 'StuDB_main_db',
filename = 'D:\DB\StuDB_main.mdf',
size = 10mb,
maxsize = 20mb,
filegrowth = 10%
)
log on
(
name = 'StuDB_log_db',
filename = 'D:\DB\StuDB_log.ldf',
size = 10mb,
maxsize = 20mb,
filegrowth = 10%
)
use StuDB
//如果系统存在此对象的表 删除
if exists(select * from sysobjects where name = 'student')
drop table student
create table student
(
sid int identity(10001001,1) primary key,
sname varchar(40),
age int,
* varchar(20)
)
select * from student
//插入数据
insert into student values('张三',22,'男')
delete from student where sid = 10001005
insert into student values(10001006,'李四',22,'男')
insert into student values(10001006,'李四',22,'男')
set identity_insert student on
insert into student(sid,sname,age,*) values(10001006,'李四',22,'男')
insert into student(sid,sname,age,*) values(10001010,'李四',22,'男')
insert into student(sid,sname,age,*) values(10001011,'李四',22,'男')
//删除
delete from student where sid = 10001005
delete from student where sid = 10001006
delete from student where sid = 10001010
delete from student where sid = 10001011
delete from student where sid = 10001007
select * from student
//数据库基本用法
exec xp_cmdshell 'mkdir D:\\DB'
//如果系统存在此对象的数据库 删除
if exists(select * from sysdatabases where name = 'StuDB')
drop database StuDB
//创建数据库StuDB
//数据库名字,文件路径,文件大小,文件最大空间,增长速度
create database StuDB
on
(
name = 'StuDB_main_db',
filename = 'D:\DB\StuDB_main.mdf',
size = 10mb,
maxsize = 20mb,
filegrowth = 10%
)
log on
(
name = 'StuDB_log_db',
filename = 'D:\DB\StuDB_log.ldf',
size = 10mb,
maxsize = 20mb,
filegrowth = 10%
)
use StuDB
//如果系统存在此对象的表 删除
if exists(select * from sysobjects where name = 'student')
drop table student
create table student
(
sid int identity(10001001,1) primary key,
sname varchar(40),
age int,
* varchar(20)
)
select * from student
//插入数据
insert into student values('张三',22,'男')
delete from student where sid = 10001005
insert into student values(10001006,'李四',22,'男')
insert into student values(10001006,'李四',22,'男')
set identity_insert student on
insert into student(sid,sname,age,*) values(10001006,'李四',22,'男')
insert into student(sid,sname,age,*) values(10001010,'李四',22,'男')
insert into student(sid,sname,age,*) values(10001011,'李四',22,'男')
//删除
delete from student where sid = 10001005
delete from student where sid = 10001006
delete from student where sid = 10001010
delete from student where sid = 10001011
delete from student where sid = 10001007
select * from student
//数据库基本用法
作者:onlyoneggp 发表于2013-1-12 23:08:19 原文链接
阅读:0 评论:0 查看评论
最新技术文章: