GiNaC/doc/tutorial ginac.texi

Richard B. Kreckel kreckel at thep.physik.uni-mainz.de
Tue Apr 10 00:03:04 CEST 2001


On Mon, 9 Apr 2001, Pearu Peterson wrote:
> On Mon, 9 Apr 2001, Christian Bauer wrote:
> 
> > - added examples for specialized expression output by tree-traversal and
> >   with the aid of archives
> 
> These examples are very useful for understanding GiNaC archive stuff
> for GiNaC beginners like me. Thanks!
> 
> However, I might have found even simpler way to extract protected
> attributes. Take, for example, indexed class that has protected attribute
> `seq'. It can be read outside of the indexed class as follows:
> 
> class wrap_indexed: public indexed {
> public:
>   const exvector & get_seq(void) const { return this->seq; }
> };
> 
> void somefunction (const indexed & obj) {
>   const exvector & seq = ((const wrap_indexed &)obj).get_seq();
>   /* Use `seq' for something */
> }

<preach>
Hmm, you know that you are abusing the language, don't you?  As a next step
step you might #define private public before #include'ing <ginac/ginac.h>.
That's just scary!  Better stick to the interfaces provided by the library.
</preach>

Regards
     -richy.
-- 
Richard Kreckel
<Richard.Kreckel at Uni-Mainz.DE>
<http://wwwthep.physik.uni-mainz.de/~kreckel/>





More information about the GiNaC-devel mailing list