Solved

Turbo C++ Container Classes

Posted on 1997-02-18
1
539 Views
Last Modified: 2013-12-27
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
Comment
Question by:Gabriel021197
1 Comment
 
LVL 1

Accepted Solution

by:
edtmihu earned 50 total points
ID: 1598452
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I recently purchased an HP EliteBook 2540p notebook/laptop. It has two video ports on it – VGA and DisplayPort. HP offers an optional docking station for the 2540p that also has both a VGA port and a DisplayPort. There are numerous online reports do…
Moving your enterprise fax infrastructure from in-house fax machines and servers to the cloud makes sense — from both an efficiency and productivity standpoint. But does migrating to a cloud fax solution mean you will no longer be able to send or re…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now