On 16/03/11 10:05, Julia Jacobson wrote:
> Hello everybody out there using FLTK,
> When trying to compile code containing the snippet from
> http://www.fltk.org/doc-2.0/html/classStringList.html with Visual C++ 2008, I
> get the error message "Cannot create instance of abstract class".
> Can anybody compile the sample code for StringList.
> Regards,
> Julia
StringList has two purely virtual functions, int children(const Menu*
menu) and const char* label(const Menu* menu, int index). The idea of
the StringList is to have an efficient way to add hundreds of thousands
of elements (as StringList is derived from StringHierarchy).
In any case, you have to derive your own class for a StringList and
override the children and label methods.
class MyStringList : public StringList {
public:
int children(const Menu* menu) {
return ((Menu*)(menu->user_data()))->number_of_items();
}
const char * label(const Menu* menu, int index) {
return ((Menu*)(menu->user_data()))->label(index);
}
};
Then it should compile. This seems like it's documented within the
internal docs but not online. I'll see if I can fix this....
Regards,
Ben.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk