stephens@motcid.UUCP (Kurt Stephens) (07/20/90)
I have found a bug in Turbo C++ ClassLib. The copy contructor for the Container class doesn't increment the ContainerIterator to dup the Container. It just loops. A paraphrasing of the original code looks something like this (I'm posting this from work, I don't have the actual code with me): ==================cut here============================================ Container::Container( Container& c ) { ContainerIterator& i = c.initIterator(); while ( (int) i != 0 ) { // This loops forever } // on non-empty Containers . . . } ===================================================================== This should be: =================cut here============================================ Container::Container( Container& c ) { ContainerIterator& i = c.initIterator(); while ( (int) i != 0 ) { i ++; } . . . } ===================================================================== I have had other problems with the ClassLib, but I can't pin them down. (HINT: Build the library with debugging info.) I have alerted Borland about the problem, but they gave no indication of when it would be updated. But they are happy to here any bug reports. So if you find em', don't be shy, let them know! Good feedback will trickle down to a better product for all of us. A side note... Does anybody have the NIH class library available, ported to Turbo C++? If not, could somebody provide the source, or tell me how to get it? Please no cutesy remarks, I don't know (or care) what "NIH" stands for, but I know what it is. ;^) Side note #2... What's wrong with the following code... ========================cut here========================================= #include <iostream.h> class BaseClass { public: virtual void identify() { ceer << "BaseClass\n"; }; }; class DerivedClass : public BaseClass { public: void identify() { cerr << "DerivedClass\n"; }; }; class AClass { public: BaseClass baseClass; AClass ( BaseClass& bc ) : baseClass ( bc ) { } }; main () { BaseClass baseclass; DerivedClass derivedclass; AClass aclassofbase ( baseclass ), aclassofderived ( derivedclass ); // // should print "BaseClass\n". OK. // aclassofbase.baseClass.identify(); // // should print "DerivedClass\n", right? // prints "BaseClass\n"!! in Turbo C++ // aclassofderived.baseClass.identify(); } ======================================================================== Am I missing something, (I've only been working in C++ for a few months) but shouldn't aclassofderived.baseClass be of type class DerivedClass, not the generic class BaseClass? Do I need to declare AClass::baseClass as virtual? Or does it have something to do with the AClass::AClass( BaseClass& ) constructor? What am I doing wrong? Thanks in advance! Kurt A. Stephens "Write modular, reusable code, machines will only get faster" UUNET: ...!uunet!motcid!stephens WRK: (708) 632-6728 -- Kurt A. Stephens UUNET: ...!uunet!motcid!stephens Motorola, Inc. WORK: 708 632 4669 EMX2500 Release Group