Class derived from std::ostream


root’s cvs from today, Win2k, MSVC7: derive a class “MyClass” from std::ostream and TObject, run rootcint on it (I did a “.L MyClass.cxx++”). Cint will show TObject, ostream and ios as base classes. std::ostream has basic_ios as virtual base class - but not MyClass. Could this be fixed?



addendum: on linux it’s different. For the same class, on RH7.3, gcc3.2.1, today’s cvs root, I get

class MyClass: public basic_ostream<char,char_traits<char> >, public basic_ios<char,char_traits<char> >, public ios_base, public TObject

So std:: is still skipped, but now ostream is basic_ostream<char,char_traits > etc, and both basic_ios and ios_base are added. Why is the linux behaviour different from that on windows? And again, could these ‘almost base classes’ be removed?

Cheers, Axel.

Hi Axel,

Where do you see this output?
Is it inside the dictionary or are you writing it yourself?
If you are writing it yourself, here is a shorter primer on how cint deal with virtual class.

The location of a virtual base class relative to the other base class depends on the complete inheritance tree. In particular, only the
most derived class in the tree can really know where the virtual base class are located in memory.

In writing C++, this means that the most derived class, constructors has to call directly the constructor not only for its immediate parent class but also for ALL its indirect virtual base classes.

CINT has an interface to return the relative offset of all the base classes. In order to implement this, CINT list the direct parent and all the indirect virtual parent in the list of base classes. When writing about code base on the cint dictionary you have to weed out the indirect virtual base class.

For example in the rootcint Shadow Class we do:

if ( (b.Property() & G__BIT_ISVIRTUAL) && !(b.Property() & G__BIT_ISDIRECTINHERIT)) { // CINT duplicates the remote virtual base class in the list scanned // by G__BaseClassInfo, we need to skip them. continue; }


Hi Philippe,

it’s both in the TBrowser’s class view and THtml’s output. One more question: why does linux have yet another virtual base class added? Is it simply because the two STL implementations differ?

I’ll put your piece of code into THtml. Thanks for this nice explanation on how Cint deals with virtual base classes!

Hi Axel,

I think it is because of the different implementation.