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# 2.0 命令行编译器
http://msdn.microsoft.com/zh-cn/library/ms379563(vs.80).aspx#mainSection
摘要:本文分析了使用 C# 命令行编译器 csc.exe 生成应用程序的过程。同时,还将向读者介绍很多为 C# 2.0 独有的编译器选项,例如,extended/reference 标志和强名称支持。阅读完本文的内容之后,您将能够轻松地在没 ......
今天突然想到B/S结构里,webform是无法取得客户端的MAC地址和硬件信息的,就突发奇想,用C/S结构,但是因为C/S结构的很多的东西不能动态,就考虑到了C/B结构
最后决定用webservice+ALC+C/B结构 ,搭建我的OA系统
努力ing ......
1.打开“我的电脑”-“工具”-“文件夹选项”-“查看”-在“显示所有文件和文件夹”选项前打勾-“确定”
2.删除以下文件夹中的内容:
x:\\Documents and Settings\\用户名\\Cookies\\下的所有文件(保留index文件)
x:\\Documents and S ......
递归链表反序
void Invert(struct node *p)
{
if(p->next==NULL) return;
if(p->next->next!=0)
Invert(p->next);
p->next->next = p;
p-> ......
(一)整数符号的陷阱
(二)浮点数的本质
(三)堆栈的内存管理结构
(四)符号解析
(五)对齐和总线错误
(六)函数指针
(七)虚函数的实现机理
(八)引用的实现机理
(九)虚拟继承对象的内存结构
(十)混合编程时的初始化顺序
(十一)数组和指针的异同 ......