3 # This file illustrates the C++ interface created by SWIG.
4 # All of our C++ classes get converted into Ruby classes.
8 # ----- Object creation -----
10 print "Creating some objects:\n"
11 c = Example::Circle.new(10)
12 print " Created circle #{c}\n"
13 s = Example::Square.new(10)
14 print " Created square #{s}\n"
16 # ----- Access a static member -----
18 print "\nA total of #{Example::Shape.nshapes} shapes were created\n"
20 # ----- Member data access -----
22 # Set the location of the object
24 # Notice how we can do this using functions specific to
29 # Now use the same functions in the base class
33 print "\nHere is their current position:\n"
34 print " Circle = (", c.x, ",", c.y, ")\n"
35 print " Square = (", s.x, ",", s.y, ")\n"
37 # ----- Call some methods -----
39 print "\nHere are some properties of the shapes:\n"
42 print " area = ", o.area, "\n"
43 print " perimeter = ", o.perimeter, "\n"
45 # Notice how the Shape#area() and Shape#perimeter() functions really
46 # invoke the appropriate virtual method on each object.
48 print "\n", Example::Shape.nshapes," shapes remain\n"