程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> 純C實現面向對象

純C實現面向對象

編輯:關於C語言

#include <stdio.h><stdlib.h>


 Interface struct



 Class struct




shape* Shape( shape_getEdges(shape * shape_getArea( _Shape(shape *

triangle * Triangle( bottom,  triangle_getEdges(triangle * triangle_getArea(triangle * _Triangle(triangle *

rectangle * Rectangle( bottom,  rectangle_getEdges(rectangle * rectangle_getArea(rectangle * _Rectangle(rectangle *
 (*getEdges)(shape* (*getArea)(
shape* Shape(* obj = (shape *) malloc(->edges =->getEdges =->getArea = shape_getEdges(shape* obj-> shape_getArea( -
 _Shape(shape *(obj ==
* (*getEdges)(triangle * (*getArea)(triangle *
triangle * Triangle( bottom, * obj = (triangle*) malloc(
    obj->super = Shape(->bottom =->height =->getEdges =->getArea = triangle_getEdges(triangle * obj->super-> triangle_getArea(triangle * (obj->bottom * obj->height) / 
 _Triangle(triangle *->(triangle ==
* (*getEdges)(rectangle * (*getArea)(rectangle *
rectangle * Rectangle( bottom, * obj = (rectangle *)malloc(
    obj->super = Shape(->bottom =->height =->getEdges =->getArea = rectangle_getEdges(rectangle * obj->super-> rectangle_getArea(rectangle * (obj->bottom * obj->
 _Rectangle(rectangle *->(obj ==
* shapeObj = Shape(, shapeObj->, shapeObj->* triangleObj = Triangle(, , triangleObj->, triangleObj->* rectangleObj = Rectangle(, , rectangleObj->, rectangleObj->

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved