But if I follow mystring.cpp example, and I try to change
GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(mystring, basic, print_func<print_context>(&mystring::do_print))
to
GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(mystring, symbol, print_func<print_context>(&mystring::do_print))
(analogously with GINAC_IMPLEMENT_REGISTERED_CLASS_OPT)
and also class mysymbol : public string becomes class mysymbol : public symbol
This is not enough. Did you change the constructors?
I leave the constructors as they are // ctors mystring::mystring() : inherited(&mystring::tinfo_static) { } mystring::mystring(const string &s) : inherited(&mystring::tinfo_static), str(s) { } mystring::mystring(const char *s) : inherited(&mystring::tinfo_static), str(s) { } then error is: $ g++ -o mystring mystring.cpp `pkg-config --cflags --libs ginac` mystring.cpp: In constructor ‘mystring::mystring()’: mystring.cpp:32: error: no matching function for call to ‘GiNaC::symbol::symbol(const GiNaC::tinfo_static_t*)’ ... The manual implicitly suggesst that this should not be a problem, so I were confused. Thanks to you, I can now see that changing them to // ctors mystring::mystring() { tinfo_key = MYSTRING_RTTI; } mystring::mystring(const string &s) : str(s) { tinfo_key = MYSTRING_RTTI; } mystring::mystring(const char *s) : str(s) { tinfo_key = MYSTRING_RTTI; } It works. I think it can be beneficial for the Tutorial (I think you are one of the developers), more pedagogical, to define the constructors in this way, because I think that they will work allways in this form, and obiously the reverse is not true, the posibility used right now calling the inherited method could be a footnote. Just for curiosity what does it means: // ctors, and w.r.t. Also I see that the archiving constructor, now in your yesterday's mysymbol.cpp, do not need to set tinfo_key this mysymbol::mysymbol(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst) { //tinfo_key = MYSYMBOL_RTTI; } compiles and executes OK. Is this correct in general terms?, the manual does not say anything about having to set tinfo_key in the archiving constructor. Also it would be beneficial to have a second example like mysymbol.cpp this in the tutorial, perhaps adding a numeric representing the value of the symbol, and redefining the evalf() method so that evaluation of the symbol uses the numeric field to compute the value, like for constants. If the derivative overloading is maintained, It would be preferable if it does something useful, as returning for symbol "e" the symbol "de" that represents its derivative with respect to symbol time "t". This way total derivatives with "t" like in clasic mechanics (my field) can be done for expresions. This has the drawback, that "t" should be a global variable in the example, and "de" a mysymbol member of mysymbol, so new constructor needed, or a mysymbol created on the fly. I hope this helps, and again, thanks a lot. I wan't to ask also about dealing with non-conmutativity of a defined symbol -something that is no clear in the Tutorial- but I will postpone the subjet. Thanks Javier Ros