Variable inheritance support: sets/gets for each class derived from a base class. Modified 'class' example.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10619 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f74439e215
commit
9c07e2a9e5
2 changed files with 58 additions and 35 deletions
|
|
@ -11,20 +11,25 @@ int main(int argc, char **argv) {
|
|||
|
||||
printf("\nA total of %d shapes were created\n", 0);
|
||||
|
||||
Circle_set_x(c, 20);
|
||||
Circle_set_y(c, 30);
|
||||
|
||||
Shape* shape = (Shape*) s;
|
||||
Shape_set_x(shape, -10);
|
||||
Shape_set_y(shape, 5);
|
||||
|
||||
printf("\nHere is their current positions:\n");
|
||||
printf(" Circle = (%f %f)\n", Circle_get_x(c), Circle_get_y(c));
|
||||
printf(" Square = (%f %f)\n", Square_get_x(s), Square_get_y(s));
|
||||
|
||||
printf("\nHere are some properties of the shapes:\n");
|
||||
Shape shapes[] = {c, s};
|
||||
Shape* shapes[] = {(Shape*) c, (Shape*) s};
|
||||
int i;
|
||||
/*
|
||||
* TODO: support for virtual functions
|
||||
for (i = 0; i < 2; i++) {
|
||||
printf(" %s\n", i ? "Square" : "Circle");
|
||||
printf(" area = %f\n", Shape_area(shapes[i]));
|
||||
printf(" perimeter = %f\n", Shape_perimeter(shapes[i]));
|
||||
}
|
||||
*/
|
||||
|
||||
// call methods directly by now
|
||||
printf("Circle perim.=%f, area=%f\n", Circle_perimeter(c), Circle_area(c));
|
||||
printf("Square perim.=%f, area=%f\n", Square_perimeter(s), Square_area(s));
|
||||
|
||||
printf("\nGuess I'll clean up now\n");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue