From: Oliver B. <obi...@gm...> - 2002-03-12 16:18:49
|
There is a nice example of a copy constructor in Chad Smith's book '[incr Tcl/Tk] from the ground up' on page 135: "...The constructor must first determine wether the commandline argument is an instance of that class type. If so, then it should initialize each of its data members with the corresponding values of the given object's data members..." ::itcl::class Radio { constructor {args} { if {![catch {$args isa Radio}]} { # The parameter is a Radio object. Copy it. copy $args return } eval configure args } private method copy {object_} ... ... } ::itcl::body Radio::copy {object_} foreach datamember .... { configure -$datamember [$object_ cget -$datamember] } ... ... } Hope this helps Oliver |