易截截图软件、单文件、免安装、纯绿色、仅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++学累了,看了很多的网站论坛,突然感觉迷茫了,c/c++到底能做什么呢?现在JAVA很热,也很好找工作,而且学起来还听说很容易入门。不用学计算机基础类的知识,可C/C++就不同了,只学编程还不行,还得学什么数据结构,算法,计算机原理,操作系统,汇编语言,编程用具等等,需要好多,感觉一 ......

c与c++的区别(基础)

为了用vc写一个最简单的 socket 程序,花费了一个下午的时间,过程中出现的错误有:
'SOCKET' : illegal use of this type as an expression
syntax error : missing ';' before 'type'
syntax error : identifier 'InitWinsock'   -->       bool   InitWinsock( ......

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++笔试题目(林锐)

本试题仅用于考查C++/C程序员的基本编程技能。内容限于C++/C常用语法,不涉及数据结构、算法以及深奥的语法。考试成绩能反映出考生的编程质量以及对C++/C的理解程度,但不能反映考生的智力和软件开发能力。
笔试时间90分钟。请考生认真答题,切勿轻视。
一、请填写BOOL , float, 指针变量 与“零值”比较的 i ......

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

static
C++中的static
  C++的static有两种用法:面向过程程序设计中的static和面向对象程序设计中的static。前者应用于普通变量和函数,不涉及类;后者主要说明static在类中的作用。
  一、面向过程设计中的static
  1、静态全局变量
  在全局变量前,加上关键字static,该变量就被定义成为一个静态全局变 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号