易截截图软件、单文件、免安装、纯绿色、仅160KB

C: 面向对象(2)

演示如何用C实现继承,重载之类的玩艺儿。VC++6.0编译通过。
#include <stdio.h>
#include <stdlib.h>
#include <string.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 char *name;
 //public members
 public void (*construct)(class Parent *this);
 public bool (*setName)(class Parent *this, const char *name);
 public char* (*getName)(class Parent *this);
 public void (*destruct)(class Parent *this);
};
class Son{
 //private members
 private class Son *this;
 //inherit properties from Parent, we use a pointer here to simulate inheritance
 private class Parent *inherit;
 //add new members
 private char* addr;
//public members
 public bool (*construct)(class Son *this); 
 public bool (*setName)(class Son *this, const char *name);
 public char* (*getName)(class Son *this);
 public bool (*setAddr)(class Son *this, const char *addr);
 public char* (*getAddr)(class Son *this);
 public void (*destruct)(class Son *this);
};
//foward declaration
//-----Members for Parent begin
void ParentConstruct(class Parent *this);
bool setName(class Parent *this, const char *name);
char *getName(class Parent *this);
void ParentDestruct(class Parent *this);
//-----Mmmbers for Parent end
//----Members for Son begin
bool SonConstruct(clas


相关文档:

c文件操作 (转)

文件
文件的基本概念
  所谓“文件”是指一组相关数据的有序集合。 这个数据集有一个名称,叫做文件名。 实际上在前面的各章中我们已经多次使用了文件,例如源程序文件、目标文件、可执行文件、库文件 (头文件)等。文件通常是驻留在外部介质(如磁盘等)上的, 在使用时才调入内存中来。从 ......

C/C++时间函数的使用

一、获取日历时间
time_t是定义在time.h中的一个类型,表示一个日历时间,也就是从1970年1月1日0时0分0秒到此时的秒数,原型是:
 typedef long time_t;        /* time value */
可以看出time_t其实是一个长整型,由于长整型能表示的数值有限,因此它能表示的最迟时间是2038年 ......

自动化测试中Python与C/C++的混合使用


背景
项目的
自动化测试中已经使用了基于Python
脚本的框架,自动化过程中最关键的问题就是如何实现桩模块。运用
Python
强大的功能,实现任何桩模块都是可能的,但是是否必须完全使用
Python
实现模块逻辑,成本是一个决定性因素。在桩模块逻辑简单的情况下,使用
Python
模拟模块逻辑不但使自动化测试的结构清 ......

C程序中main参数argv和argc

      命令行界面的程序,通常都需要输入命令行参数帮助程序执行。main是最典型的此类应用,main的参数之前都被忽略掉了。
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
   int count;
   printf("The command line has %d arguments:\n", ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号