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
相关文档:
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的变参问题与print函数的实现
我们在C语言编程中会遇到一些参数个数可变的函数,例如printf() 这个函数,它的定义是这样的: int printf( const char* format, ...);
它除了有一个参数format固定以外,后面跟的参数的个数和类型是可变的,例如我们可以有以下不同的调用方法:
printf("%d",i);
&nb ......
今天突然想到B/S结构里,webform是无法取得客户端的MAC地址和硬件信息的,就突发奇想,用C/S结构,但是因为C/S结构的很多的东西不能动态,就考虑到了C/B结构
最后决定用webservice+ALC+C/B结构 ,搭建我的OA系统
努力ing ......
本试题仅用于考查C++/C程序员的基本编程技能。内容限于C++/C常用语法,不涉及数据结构、算法以及深奥的语法。考试成绩能反映出考生的编程质量以及对C++/C的理解程度,但不能反映考生的智力和软件开发能力。
笔试时间90分钟。请考生认真答题,切勿轻视。
一、请填写BOOL , float, 指针变量 与“零值”比较的 i ......
#include <stdio.h>
#define LL unsigned long long int
inline LL mod(LL a,LL b)
{
while (a>=b)
a-=b;
return a;
}
//a*b mod c
inline LL MulAndMod(LL a, LL shl_b,LL c)
{
LL val,pre;
pre = mod(a,c);
val = 0;
......