/c-interfaces

C interface pattern showcase

Primary LanguageC

c-interfaces

C interface pattern showcase project


Overview

This project defines a shape_interface structure with three "virtual" functions: type, area, perimiter.

There are two "derived" structures: circle and rectangle which "implement" the shape_interface.

In the main.c file there is a function print_shape_params which takes the interface and the object as parameters and prints the values of all three interface functions.


Build and run

> gcc -o shapes app/main.c source/*.c -I include/
> ./shapes