1.virtual 函数版本
class GameCharacter{
public:
virtual int healthValue() const; //返回人物的健康指数, derived classes 可重新定义它
};
2.使用 non-virtual interface 手法,那是 Template Method 设计模式的一种特殊形式。
让客户通过 public non-virtual 成员函数间接调用 private virtual 函数
class GameCharacter{
pu...
分类:
编程语言 时间:
2014-07-15 22:36:18
阅读次数:
364
经验:请使用 member function templates(成员函数模板)生成"可接受所有兼容类型"的函数
示例:泛化 copy 构造函数
temmplate
class SmartPtr{
public:
template
SmartPtr(const SmartPtr &other) //member template, 为了生成 copy 构造函数
: heldPtr(other.get()){...}
T *get() const...
分类:
编程语言 时间:
2014-07-15 13:10:24
阅读次数:
319
题目链接:点击打开链接
#include
#include
#include
#include
#include
using namespace std;
const int MAX_N = 507;
const long long INF = (long long)1e15;
typedef long long ll;
typedef pair pii;
ll C[MAX_N][MA...
分类:
其他好文 时间:
2014-07-15 10:44:20
阅读次数:
229
#includevoid main(){const int count = 5;//定义数量struct student{char name[80];float math,eng;float aver;}stu[count],temp;//输入for (int i = 0; i stu[sub].a...
分类:
编程语言 时间:
2014-07-14 21:23:30
阅读次数:
247
1 函数简介
功 能: 使用快速排序例程进行排序
头文件:stdlib.h
用 法: void qsort(void *base,int nelem,int width,int (*fcmp)(const void *,const void *));
参数: 1 待排序数组首地址
2 数组中待排序元素数量
3 各元素的占用空间大小
4 指向函数的指针,用于确定排序的顺序
...
分类:
编程语言 时间:
2014-07-14 18:39:16
阅读次数:
408
在iOS开发中,为了数据的安全经常对内容进行加密,在这儿我们对常用的加密算法进行了总结:
1、MD5
+ (NSString *)md5Hash:(NSString *)str {
const char *cStr = [str UTF8String];
unsigned char result[16];
CC_MD5( cStr, strlen(cStr), re...
分类:
移动开发 时间:
2014-07-14 18:17:16
阅读次数:
265
有一定的难度,作者只做了前三题!
题目请见 http://download.csdn.net/download/wangpegasus/5701765
1、char *find_char(char const *source, char const *chars)
{
char *ptr;
if(source != NULL && chars != NULL)
{
for (; ...
分类:
其他好文 时间:
2014-07-14 18:16:35
阅读次数:
289
点击打开链接
题意:货币兑换,换取最大钱币;
解析:构图,spfa
#include
#include
#include
#include
#include
using namespace std;
const int maxn = 1005;
double cost[ maxn ][ maxn ], dis[ maxn ];
int vis[ maxn ];
int n, m;
c...
分类:
其他好文 时间:
2014-07-14 17:37:44
阅读次数:
147
交换操作
class HasPtr
{
friend void fun2();
friend void swap(HasPtr&, HasPtr&);
public:
// HasPtr()=default;
HasPtr(const string &s=string()):ps(new string(s)), i(0){}
//对ps指向的stri...
分类:
编程语言 时间:
2014-07-14 17:18:06
阅读次数:
314
int fscanf( FILE *stream, const char *format [, argument ]... );
下面是csdn的例子:
/* FSCANF.C: This program writes formatted
* data to a file. It then uses fscanf to
* read the various data back from...
分类:
其他好文 时间:
2014-07-14 16:15:19
阅读次数:
207