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
相关文档:
今天突然想到B/S结构里,webform是无法取得客户端的MAC地址和硬件信息的,就突发奇想,用C/S结构,但是因为C/S结构的很多的东西不能动态,就考虑到了C/B结构
最后决定用webservice+ALC+C/B结构 ,搭建我的OA系统
努力ing ......
演示如何用C实现继承,重载之类的玩艺儿。VC++6.0编译通过。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef class
#define class struct
#endif
#ifndef private
#define privat ......
1.打开“我的电脑”-“工具”-“文件夹选项”-“查看”-在“显示所有文件和文件夹”选项前打勾-“确定”
2.删除以下文件夹中的内容:
x:\\Documents and Settings\\用户名\\Cookies\\下的所有文件(保留index文件)
x:\\Documents and S ......
1. 创建类型为Win-32 Static Library的工程:
(1)填写工程名称,工程名称不与已经存在库名相同即可,如mylib;
(2)默认配置,直接点击完成、确定;
(3)在这个工程下新建一个类型为C/C++ Header File的文件,文件名为liwenying.h;
(4)在liwenying.h下面输入代码
......