Question : Problem: Turbo C++ Container Classes

I seem to be having a little bit of trouble using the container class TListImp provided by Turbo C++. I have created my own typedef ListImp as an integer version of this template and I am using it in the implementation of a graph ADT. However, when I try to use the Detach member function of this class I create a general protection fault in the processor. Has anyone used this template and if so could they please offer any advice or maybe even produce a peice of example code which I may find useful?

Answer : Problem: Turbo C++ Container Classes

I don't TC. But this works with BC5.01:
#include

class MyInteger
{
public:
      MyInteger() : i( 0 ) {;}
  MyInteger( int _i ) : i( _i ) {;}
  virtual ~MyInteger(){;}
      int operator == ( const MyInteger _FAR& test1 ) const { return( test1.i == i ); }
private:
      int i;
};

typedef TListImp MyIntegerList;

#pragma argsused
int WINAPI WinMain(
    HINSTANCE  hInstance,      // handle of current instance
    HINSTANCE  hPrevInstance,      // handle of previous instance
    LPSTR  lpszCmdLine,      // pointer to command line
    int  nCmdShow       // show state of window
   )
{
      MyIntegerList list;
  int i;
  for ( i = 0; i < 1000; i++ )
        {
        list.Add( MyInteger( i ) );
    }
  for ( i = 0; i < 1000; i+=2 )
        {
        list.Detach( MyInteger( i ) );
    }
  return( 0 );
}

Regards Michael
Random Solutions  
 
programming4us programming4us