3 # This file illustrates the high level C++ interface.
4 # In this case C++ classes work kind of like Tk widgets
6 catch { load .
/example
[info sharedlibextension
] example
}
8 # ----- Object creation -----
10 puts "Creating some objects:"
12 puts " Created circle [c cget -this]"
14 puts " Created square [s cget -this]"
16 # ----- Access a static member -----
18 puts "\nA total of $Shape_nshapes shapes were created"
20 # ----- Member data access -----
22 # Set the location of the object
24 c configure
-x 20 -y 30
25 s configure
-x -10 -y 5
27 puts "\nHere is their current position:"
28 puts " Circle = ([c cget -x], [c cget -y])"
29 puts " Square = ([s cget -x], [s cget -y])"
31 # ----- Call some methods -----
33 puts "\nHere are some properties of the shapes:"
35 puts " [$o cget -this]"
36 puts " area = [$o area]"
37 puts " perimeter = [$o perimeter]"
40 # ----- Delete everything -----
42 puts "\nGuess I'll clean up now"
44 # Note: this invokes the virtual destructor
48 puts "$Shape_nshapes shapes remain"