• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 693
  • Last Modified:

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?
0
Gabriel021197
Asked:
Gabriel021197
1 Solution
 
edtmihuCommented:
I don't TC. But this works with BC5.01:
#include <classlib\listimp.h>

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<MyInteger> 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
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now