LW_OOPC.H 面向对象C MISOO 头文件

来源:互联网 发布:王克勤记者知乎 编辑:程序博客网 时间:2024/06/04 19:35

Use Case(用例)的主要内涵及其表达为:

1)描述该服务的名称及返回的信息类型,她描述What

2)描述服务过程中,用户与系统之间有哪些交互,其描述How和When。但是请留意,这个How不是员工作汉堡的How,而是用户与系统如何交互的How。

3)描述用户的角色,她描述Who

/////////////////////////////////////////////////////////////////////////////////////

动态型(Dynamic):使用malloc函数

静态型(Static):标准型;不用malloc,其对象不是在程序执行期间才去分配空间的。而是与一般的int,char形态的变量一样,在编译期间就留下内存空间了,不需要在执行期间通过malloc来取得内存空间。

纯粹静态型(pure STATIC)精简型;避免使用指针来调用函数。即不调用new函数。

/*  lw_oopc_kc.h */ #ifndef LOOPC_H #define LOOPC_H #include <malloc.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     */


0 0
原创粉丝点击