-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdog.h
46 lines (35 loc) · 1.08 KB
/
dog.h
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef DOG_H
#define DOG_H
#include <stdlib.h>
#include <string.h>
#include "error.h"
// INHERITS FROM ANIMAL
#include "animal.h"
typedef struct {
animal_t super;
void* private;
} dog_t;
// Creates a dog, takes fur color and size. Returns pointer to dog. This copies
// the strings.
int dog_new (dog_t* self, const char* name, const char* furColor, const char* size);
// Deletes a dog. Takes pointer to dog created with dog_ctor D:
int dog_delete (dog_t* self);
// Gets the fur color passed to the constructor, takes pointer to dog created
// with dog_ctor.
const char* dog_getFurColor (dog_t* self);
// Gets the size passed to the constructor, takes pointer to dog created with
// dog_ctor.
const char* dog_getSize (dog_t* self);
// Create a nice structure to expose them in :D
static const struct {
int (*new)(dog_t*, const char*, const char*, const char*);
int (*delete)(dog_t*);
const char* (*getFurColor)(dog_t*);
const char* (*getSize)(dog_t*);
} Dog = {
.new = &dog_new,
.delete = &dog_delete,
.getFurColor = &dog_getFurColor,
.getSize = &dog_getSize
};
#endif // DOG_H