C: 面向对象(3)
以下代码演示如何用C来模拟多态。gcc版本:3.4.4
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
#ifndef class
#define class struct
#endif
#ifndef private
#define private
#endif
#ifndef public
#define public
#endif
#ifndef protected
#define protected
#endif
#ifndef bool
#define bool int
#endif
#ifndef true
#define true 1
#endif
#ifndef false
#define false 0
#endif
class Parent{
//private members
private class Parent *this;
private size_t len;
//public members
public size_t (*length)(class Parent *this);
public void (*construct)(class Parent *this);
public void (*print)(class Parent *this);
public void (*destruct)(class Parent *this);
};
class Son{
//private members
private class Son *this;
//inherit
private class Parent *inherit;
//public members
public size_t (*length)(class Son *this);
public bool (*construct)(class Son *this);
public void (*print)(class Son *this);
public void (*destruct)(class Son *this);
};
//forward declaration
void ParentConstruct(class Parent *this);
void ParentPr
相关文档:
背景
项目的
自动化测试中已经使用了基于Python
脚本的框架,自动化过程中最关键的问题就是如何实现桩模块。运用
Python
强大的功能,实现任何桩模块都是可能的,但是是否必须完全使用
Python
实现模块逻辑,成本是一个决定性因素。在桩模块逻辑简单的情况下,使用
Python
模拟模块逻辑不但使自动化测试的结构清 ......
#include <stdio.h>
#define LL unsigned long long int
inline LL mod(LL a,LL b)
{
while (a>=b)
a-=b;
return a;
}
//a*b mod c
inline LL MulAndMod(LL a, LL shl_b,LL c)
{
LL val,pre;
pre = mod(a,c);
val = 0;
......
一个正则表达式的教程可以参看(里面有个测试正则表达式的工具)
http://unibetter.com/deerchao/zhengzhe-biaodashi-jiaocheng-se.htm#ad
正则表达是用来匹配字符串的好东东。
如果用户熟悉Lin ......
菜单和加速键密切地联系在一起。这两种资源类型联手协作,让用户能更容易地完成任务。大家都知道菜单是什么——它是分层命令结构的物理表示。加速键提供该结构的快捷方式,以提高用户操作的速度。例如,要创建一个新文件,通常用File | New(文件|新建)命令或CTRL-N加速键,两种方法可以产生相同的结果。
Visua ......