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

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


相关文档:

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/C++ static和可重入概念

static
C++中的static
  C++的static有两种用法:面向过程程序设计中的static和面向对象程序设计中的static。前者应用于普通变量和函数,不涉及类;后者主要说明static在类中的作用。
  一、面向过程设计中的static
  1、静态全局变量
  在全局变量前,加上关键字static,该变量就被定义成为一个静态全局变 ......

linux C使用管道通信(一)

 Linux中的进程通信
1.管道
   函数原型:int pipe(int filedes[2]);
   函数返回值: 正确返回0;错误返回-1
   其中的文件描述符filedes[0]是用来读取数据的,filedes[1]是用来写数据的。
例子1:
#include<stdio.h>
#include<stdlib.h>
#include<u ......

C 基础

递归链表反序
void Invert(struct node *p)
{
     if(p->next==NULL) return;
     if(p->next->next!=0)
          Invert(p->next);
    p->next->next = p;
    p-> ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号