diff --git a/Figure.h b/Figure.h index 0679cbf..5bda2bd 100644 --- a/Figure.h +++ b/Figure.h @@ -32,11 +32,11 @@ static inline void Figure_destroy (Figure *this) { this->vtable->destroy (this); } -static inline void Figure_draw (const struct Figure *this) +static inline void Figure_draw (const Figure *this) { this->vtable->draw (this); } -static inline double (*area) (const struct Figure *this) +static inline double Figure_area (const Figure *this) { return this->vtable->area (this); } @@ -44,6 +44,6 @@ static inline double (*area) (const struct Figure *this) /* considered to be protected */ void Figure_constructor (Figure *this); void Figure_destructor (Figure *this); -void Figure_copy (struct Figure *dest, const struct Figure *src); +void Figure_copy (Figure *dest, const Figure *src); #endif // __FIGURE_H__ diff --git a/Makefile b/Makefile index 4739c01..c51b7d6 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# Makefile generated by command: smake.sh -t main --cflags=-fms-extensions +# Makefile generated by command: smake.sh -t main # This file is generated with smake.sh. # You can use this make file with instruction make to # use one of build mode: debug, profile, develop, release. @@ -18,7 +18,7 @@ TARGET0=main TARGETS= $(TARGET0) CC=cc CXX=c++ -CFLAGS := -fms-extensions $(CFLAGS) +CFLAGS := $(CFLAGS) CXXFLAGS := $(CXXFLAGS) LDFLAGS := $(LDFLAGS) LIBS= @@ -96,8 +96,7 @@ clean: #________________________________| target_objs0 = \ main.o \ - ColoredSquare.o \ - Square.o + Figure.o $(TARGET0): $(target_objs0) $(CC) $(LDFLAGS) -o $@ $(target_objs0) @@ -105,21 +104,13 @@ $(TARGET0): $(target_objs0) main.o: \ main.c \ - ColoredSquare.h \ Figure.h \ Object.h \ - Square.h + Polygon.h \ + Rhomb.h -ColoredSquare.o: \ - ColoredSquare.c \ - ColoredSquare.h \ +Figure.o: \ + Figure.c \ Figure.h \ - Object.h \ - Square.h - -Square.o: \ - Square.c \ - Figure.h \ - Object.h \ - Square.h + Object.h diff --git a/Object.h b/Object.h index 89670c1..06d8d09 100644 --- a/Object.h +++ b/Object.h @@ -7,7 +7,7 @@ typedef struct Object { /* Object methods */ const char* (*type) (); - struct Object* (*clone) (const Object *this); + struct Object* (*clone) (const struct Object *this); void (*destroy) (struct Object *this); } *vtable; diff --git a/Polygon.h b/Polygon.h index 440bf0b..0100c3a 100644 --- a/Polygon.h +++ b/Polygon.h @@ -30,7 +30,7 @@ typedef struct Polygon } Polygon; -Polygon* Polygon_new (const struct *points); +Polygon* Polygon_new (const struct point *points); static inline const char* Polygon_type (const Polygon *this) { @@ -59,7 +59,7 @@ static inline double Polygon_area (const Polygon *this) static inline double Polygon_max_diag (const Polygon *this) { - return this->max_diag (this); + return this->vtable->max_diag (this); } /* considered to be protected */ diff --git a/Rhomb.h b/Rhomb.h index d090337..31890ca 100644 --- a/Rhomb.h +++ b/Rhomb.h @@ -25,15 +25,11 @@ typedef struct Rhomb } *vtable; /* derived from Polygon */ - struct point - { - double x, y; - - } *points; + struct point *points; } Rhomb; -Rhomb* Rhomb_new (const struct *points); +Rhomb* Rhomb_new (const struct point *points); static inline const char* Rhomb_type (const Rhomb *this) { @@ -55,17 +51,20 @@ static inline void Rhomb_draw (const Rhomb *this) this->vtable->draw (this); } -static int double Rhomb_area (const Rhomb *this) +static inline double Rhomb_area (const Rhomb *this) { - return this->vtable_area (this); + return this->vtable->area (this); } static inline double Rhomb_max_diag (const Rhomb *this) { - return this->max_diag (this); + return this->vtable->max_diag (this); } -static inline int Rhomb_is_square (const Rhomb *this); +static inline int Rhomb_is_square (const Rhomb *this) +{ + return this->vtable->is_square (this); +} /* considered to be protected */ void Rhomb_constructor (Rhomb *this); diff --git a/main.c b/main.c index 79b3d72..8f05298 100644 --- a/main.c +++ b/main.c @@ -1,10 +1,10 @@ #include -#include "ColoredSquare.h" +#include "Rhomb.h" int main (void) { - unsigned long i = 0; +/* unsigned long i = 0; Figure *fig[3]; fig[0] = (Figure *) Square_new (1); @@ -38,10 +38,11 @@ int main (void) /*goto end; err: end:*/ - for (i = 0; i < sizeof (fig) / sizeof (Figure *); i++) +/* for (i = 0; i < sizeof (fig) / sizeof (Figure *); i++) { fig[i]->vtable->destroy (fig[i]); } +*/ return 0; }