Added for cycle showing polymorphism

This commit is contained in:
Kolan Sh 2012-04-30 19:34:43 +04:00
parent 85e4dfa13d
commit 782cdd4cf1
1 changed files with 4 additions and 4 deletions

8
main.c
View File

@ -20,7 +20,9 @@ int main (int argc, char *argv[])
for (i = 0; i < sizeof (fig) / sizeof (Figure *); i++) for (i = 0; i < sizeof (fig) / sizeof (Figure *); i++)
{ {
printf ("--- type = %s ---\n", fig[i]->vtable->type (fig[i])); puts ("---");
printf ("type = %s\n", fig[i]->vtable->type (fig[i]));
fig[i]->vtable->draw (fig[i]); fig[i]->vtable->draw (fig[i]);
@ -31,10 +33,8 @@ int main (int argc, char *argv[])
printf ("diag_length(%lu) = %f\n", printf ("diag_length(%lu) = %f\n",
(unsigned long) fig[i], (unsigned long) fig[i],
((Square *) fig[i])->vtable->diag_length (fig[i])); ((Square *) fig[i])->vtable->diag_length (fig[i]));
puts ("---\n");
} }
puts ("---");
/*goto end; /*goto end;
err: err: