用C语言实现面向对象编程
作者:网络转载 发布时间:[ 2013/7/11 10:37:14 ] 推荐标签:
附:lw_oopc_kc.h 宏文件内容
/* lw_oopc_kc.h */
#ifndef _LW_OOPC_H
#define _LW_OOPC_H
#include <stdlib.h>
#define CLASS(type) typedef struct type type; struct type
#ifndef LW_OOPC_PURE_STATIC
#ifndef LW_OOPC_STATIC
#ifndef LW_OOPC_DYNAMIC
#define CTOR(type)
void* type##Setting(type*);
void* type##New()
{
struct type *t;
t = (struct type *)malloc(sizeof(struct type));
return type##Setting(t);
}
void* type##Setting(type *t)
{
#else
#define CTOR(type)
void* type##New()
{
struct type *t;
t = (struct type *)malloc(sizeof(struct type));
#endif
#else
#define CTOR(type)
void* type##Setting(type *t)
{
#endif
#endif
#define END_CTOR return (void*)t; }
#define FUNCTION_SETTING(f1, f2) t->f1 = f2;
#define IMPLEMENTS(type) type type
#define INTERFACE(type) typedef struct type type; struct type
#endif
/* end */

sales@spasvo.com