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.so example}
7
catch { load ./example.dll example} ;# Windows
9
# ----- Object creation -----
11
puts "Creating some objects:"
13
puts " Created circle [c cget -this]"
15
puts " Created square [s cget -this]"
17
# ----- Access a static member -----
19
puts "\nA total of $Shape_nshapes shapes were created"
21
# ----- Member data access -----
23
# Set the location of the object
25
c configure -x 20 -y 30
26
s configure -x -10 -y 5
28
puts "\nHere is their current position:"
29
puts " Circle = ([c cget -x], [c cget -y])"
30
puts " Square = ([s cget -x], [s cget -y])"
32
# ----- Call some methods -----
34
puts "\nHere are some properties of the shapes:"
36
puts " [$o cget -this]"
37
puts " area = [$o area]"
38
puts " perimeter = [$o perimeter]"
41
# ----- Delete everything -----
43
puts "\nGuess I'll clean up now"
45
# Note: this invokes the virtual destructor
49
puts "$Shape_nshapes shapes remain"