易截截图软件、单文件、免安装、纯绿色、仅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


相关文档:

linux内核移植s3c2410,准备工作

1.首先是获得linux内核源码,好像是废话,下载地址如下:ftp://ftp.kernel.org/pub/linux/kernel/v2.6/下载:
linux-2.6.16.22.tar.bz2  patch-2.6.22.6.bz2
上面一步需要说明的是一般而言,linux内核的各个补丁文件是根据某个linux内核的版本号来作的patch。
将上面的两个压缩文件解压:
tar jxvf linux-2.6.22.ta ......

C#中C/C++程序员注意问题

1、C/C++程序员请注意,不能在case语句不为空时“向下执行”。
  2、值类型和引用类型之间的区别:C#的基本类型(int,char等)都是值类型,是在栈中创建的。而对象是引用类型,创建于堆中,需要使用关键字new。
  3、在C#中通过实例访问静态方法或成员变量是不合法的,会生成编译器错误。但是我们可以通过声 ......

Python 使用C代码——swig

Ref : http://www.swig.org/translations/chinese/tutorial.html
假设你有一些c你想再加Python.。举例来说有这么一个文件example.c
 /* File : example.c */
 #include <time.h>
 double My_variable = 3.0;
 int fact(int n) {
     if (n <= 1) return 1;
&nbs ......

C/C++ static和可重入概念

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

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号