|
To call a run-time virtual method, the developer calls an entity's
call_method method with the appropriate
METHOD_ID and
METHOD_ARGS. This method returns a logical value indicating whether or not the operation was performed. The caller should check this value before attempting to use any return values from the run-time method. Refer to Example 8-17.
|
|
|
C++ Example
|
|
|
// Get the identifier for a method named "sketch" using
|
|
// SKETCH_ARGS
|
|
static METHOD_ID sketch_method_id("sketch", "sketch_args");
|
|
|
// Execute the sketch method associated with this entity type
|
|
ok = entity->call_method(sketch_method_id, SKETCH_ARGS
|
|
(item, color, trans));
|
|
|
// Check for supported operation before using result
|
|
if (ok) { . . . }
|
|
|
Example 8-17. Calling Methods
|