CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//OOP in C (classes, methodes(~), attributes and simple inheritance)
//by baptiste prunier
/*
Output should be :
2D : 0 3
3D : 0 2 5
*/
/*
I did not explain va_arg, va_start,
va_end and va_list as they are basic
functions and type of stdarg.h, but
you should google them, they are
really interesting C features :)
*/
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#define OBJECT __attribute__((cleanup(_Delete)))
/* Class object and function */
struct Class{
size_t size;
void * (*ctor)(void * self,va_list * args);
void * (*dtor)(void * self);
void * (*clon)(const void * self);
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run