mirror of
https://gitee.com/apaki/cmake_demo.git
synced 2025-05-17 20:01:36 +08:00
33 lines
526 B
C
33 lines
526 B
C
|
|
#ifndef _SHAPE_H_
|
|
#define _SHAPE_H_
|
|
|
|
#include "common.h"
|
|
|
|
#define VIRTUAL
|
|
#define PRIVATE static
|
|
|
|
#define ASSERT_CALL_VIRTUAL_METHOD() assert(!("can't call abstract method"))
|
|
|
|
struct _virtual_table
|
|
{
|
|
VIRTUAL double (*area)(void *self, void *parent);
|
|
VIRTUAL void (*draw)(void *self, void *parent);
|
|
};
|
|
|
|
struct _shape
|
|
{
|
|
struct _shape *self;
|
|
|
|
struct _virtual_table vtb;
|
|
};
|
|
|
|
|
|
struct _shape *shape_new(void);
|
|
|
|
double shape_area(void *self, void *parent);
|
|
void shape_draw(void *self, void *parent);
|
|
|
|
#endif
|
|
|