Added garfield and snoopy classes to ./example which are derived from the cat and dog classes.

This commit is contained in:
Johannes Findeisen 2026-10-02 23:38:40 +02:00
commit 32e7d0b337
13 changed files with 1519 additions and 69 deletions

View file

@ -64,4 +64,22 @@ extern const ooc_class Cat_class;
*/
Cat *cat_new(const char *name, int age, const char *colour);
/*
* Initialise the members Cat owns, so a subclass constructor can build the Cat
* part of a larger object instead of duplicating it.
*
* This is the second link in the chain of constructors below Animal: a subclass
* of Cat calls this, gets Cat's vtable installed, and then overwrites the
* vtable with its own the same way cat_new() does.
*
* The caller supplies storage that ooc_new() has already allocated and
* zeroed. On failure the object is left exactly as it was found, so the caller
* may release it without a destructor having anything to do.
*
* Returns 0, or -1 for a NULL cat, an already initialised one, or a failed copy
* of the colour. Requires zero-initialised members and external synchronization
* between constructors in different threads.
*/
int cat_init(Cat *cat, const char *name, int age, const char *colour);
#endif /* CAT_H */