摘要: #include "createsony.h"#include "sony.h"enum Technology{PUREFLAT,PLASMA,LIQUIDCRYSTAL,NANOMETER};void fn(Sony* s){ Sony2 * ps2 = dynamic_cast<Sony2*>(s); //增加 if(ps2) ps2->adjustLight(); //否则不用 ps2->adjustVolume(); ps2->switchChannel();}void createSonyObject(Create 阅读全文
posted @ 2012-02-18 23:30 简单--生活 阅读(293) 评论(0) 推荐(0) 编辑
摘要: //13.6 系统扩展(System Extension)//13.6.1 新添加一个界面(Adding One Interface)//添加一个sony2.h 做为调整亮度的操作,他继承者sony.h//由Sony派生Sony2#include "createsony.h"#include "sony.h"enum Technology{PUREFLAT,PLASMA,LIQUIDCRYSTAL};void fn(Sony* s){ Sony2 * ps2 = dynamic_cast<Sony2*>(s); //增加 if(ps2) ps 阅读全文
posted @ 2012-02-18 22:02 简单--生活 阅读(338) 评论(0) 推荐(0) 编辑
摘要: //13.5.1 面向对像的模块(Object-Oriented Module)//13.5.2 Sony类层次结构(Class Sony Hierarchy)//纯平(PureFlat) 等离子(Plasma) 液晶(Liquid Crystal)//例如,若等离子类中有公共操作"等离子图像变换",我们在fn函数中获得了Sony类指针,并确认为等离子29英寸电视机,于是进行以下操作/*void fn(Sony* sp){ B29* b = dynamic_cast<B29*>(sp); if(b) b->切换频道(); //okPlasma* p = d 阅读全文
posted @ 2012-02-18 01:46 简单--生活 阅读(245) 评论(0) 推荐(0) 编辑
摘要: //13.4 抽像类做界面(Abstract Class As Interface)//13.4.1 抽像基类方案(The Abstract Base-Class Scheme)//13.4.2 抽像基类IDate(Abstract Base-Class IDate)//我们针Date类的公有成员函数提取出来做成纯虚函数,构成一个抽像类IDate,而Date类则继承之//13.4.3 创建Date对像(Creating Date Objects)//13.4.4 子类Date(Subclass Date)//为了适应抽像类作为界面的形式,Date类应包含idate.h文件,直接继承IDate类 阅读全文
posted @ 2012-02-16 23:23 简单--生活 阅读(255) 评论(0) 推荐(1) 编辑
摘要: $MapString="116.310634759589,39.990045537862,46#116.310371735567,39.989799696735005,44#116.310489333624,39.989904135209,43#116.31047961062,39.989998263946,42.5#116.310506600338,39.990206973256,52.5#116.310506600338,39.990206973256,52.5#116.311968822793,39.99050754819,43#116.312106621229,39.9904 阅读全文
posted @ 2012-02-16 16:36 简单--生活 阅读(356) 评论(0) 推荐(0) 编辑
摘要: //在()函数返回一个参考指数禄字符串中的元素。//在()函数比[]操作更安全,因为它不会让你以外的字符串的界限的参考项目。#include <iostream>#include <vector>using namespace std;int main(){ vector<int> v(5,1); //这里访问访问到地址以外的数据信息 /*for(int i=0; i<10; i++){ cout<<"Element "<<i<<" is "<<v[i]<&l 阅读全文
posted @ 2012-02-15 22:53 简单--生活 阅读(154) 评论(0) 推荐(0) 编辑
摘要: //用DateMid_New类做界面 ^-^有点不够意思了,这个都还写出来有点错,自己还差点找不到#include "datemid_new.h"#include <iostream>int main(){ DateMid_New d(2005,9,9), e(42211); std::cout<<d; std::cout<<++d<<e; system("pause"); return 0;} //DateMid_New作为应用程序界面#ifndef HEADER_DATEMID_NEW#define H 阅读全文
posted @ 2012-02-15 22:18 简单--生活 阅读(237) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <string>using namespace std;void assign(){ string str="assign"; char str_one='i'; cout<<"size_type num, const char& val\n"; //添加指定数量的字符到str中去 str.assign(6,str_one); cout<<str<<endl; //添加字符串到str中去 string str_two 阅读全文
posted @ 2012-02-15 13:53 简单--生活 阅读(254) 评论(0) 推荐(1) 编辑
摘要: //append一共有六种重载类型#include <iostream>#include <string>using namespace std;void append(string& str, int number, char& s){ //cout<<str<<endl; //操把这里的类型弄错了,s只能是只能是字符而不能是string串 str.append(number,s); cout<<str<<endl; //str.append(number,s); string str_one=" 阅读全文
posted @ 2012-02-15 12:25 简单--生活 阅读(399) 评论(0) 推荐(0) 编辑
摘要: //日期的天数版本类文件#ifndef HEADER_DATE_TWO#define HEADER_DATE_TWO#include <iostream>using namespace std;class Date_Two{ int absday; int year, month, day;protected: //计算年月日的天数 void ymd2i(int y, int m, int d); static const int tians[]; bool isLeapYear(); //判断是否为闰年public: //构造函数 Date_Two(const string&am 阅读全文
posted @ 2012-02-14 23:25 简单--生活 阅读(481) 评论(0) 推荐(0) 编辑
简单--生活(CSDN)