1
# This file illustrates the shadow-class C++ interface generated
4
dyn.load('example_wrap.so')
5
source('example_wrap.R')
8
# ----- Object creation -----
10
print("Creating some objects:")
12
print (" Created circle")
14
print (" Created square")
16
# ----- Access a static member -----
18
sprintf("A total of %d shapes were created", Shape_nshapes())
20
# ----- Member data access -----
22
# Set the location of the object
30
print("Here is their current position:")
31
sprintf(" Circle = (%f, %f)", circle$x,circle$y)
32
sprintf(" Square = (%f, %f)", square$x,square$y)
34
# ----- Call some methods -----
36
print ("Here are some properties of the shapes:")
38
sapply(c(circle, square),
40
sprintf(" area = %f perimeter = %f", o$area(), o$perimeter())
43
print("Guess I'll clean up now")
47
sprintf("%d shapes remain", Shape_nshapes())