How to access to the method of the specified classIn the capter: [To cast the WSCbase* into the specified class], you can cast WSCbase* to the pointer of the specified class. Following example shows accessing of the method of WSClist class. WSClist class displays the list of some strings, and the WSClist::addString() method adds the specified string to the list.
#include "WSClist.h" //use WSClist class.
...
void some_function(...){
//get the instance: name=list001, class=WSClist.
WSCbase* object;
object = (WSCbase*)WSGIappObjectList()->getInstance("WSClist","list001");
//cast to WSClist pointer, and execute WSClist::addItem().
WSClist* list = (WSClist*)object->cast("WSClist");
list->addItem("sample string",0)
In the example, it gets the instance which name is "list001"
and which class is WSClist from the instance management.
The instance management returns WSCbase*,
it casts WSCbase* to WSClist*,and executes the WSClist::addItem() method.
In the top of the source, we must include the headder file of the class.
Document Release 3.0 For Use with Wide Studio Release 3.0, Summer 2002
|