PRODUCT : Borland C++ NUMBER : 1734 VERSION : All OS : All DATE : October 25, 1993 PAGE : 1/3 TITLE : A BIDS example: BI_SDoubleListImp This TI contains an example of the BI_SDoubleListImp<> template since there is no example for in the manual. This TI also serves as a supplement to TI1035 which discusses the operators and constructors necessary for some of BIDS templates. As you can see the amount of work required to add the necessary operators and constructors per TI1035 is minimal. The following is a working example, use this as a template for your own project. #include #include #include class JazzStg{ char* string; public: //--------------------- Default constructor required by TI1035 JazzStg() {string = 0;} JazzStg(JazzStg&); JazzStg(char*); ~JazzStg() {if (string) delete string;} operator char*(); //------ These are the operators you need to define per TI1035 int operator<(JazzStg&); int operator==(JazzStg&); int operator!=(JazzStg&); }; //------------------------- Copy constructor required by TI1035 JazzStg::JazzStg(JazzStg& s) { char* cp = (char*) s; string = new char [strlen(cp) + 1]; strcpy(string, cp); } JazzStg::JazzStg(char* cp) { string = new char [strlen(cp) + 1]; strcpy(string, cp); PRODUCT : Borland C++ NUMBER : 1734 VERSION : All OS : All DATE : October 25, 1993 PAGE : 2/3 TITLE : A BIDS example: BI_SDoubleListImp } JazzStg::operator char*() { if (string) return string; else return "No string defined"; } //------------------------------------ Definition of operator < int JazzStg::operator<(JazzStg& c) { return stricmp(string, (char*) c) < 0 ? 1 : 0; } //----------------------------------- Definition of operator == int JazzStg::operator==(JazzStg& c) { return stricmp(string, (char*) c) == 0 ? 1 : 0; } //------------------------------------ Definition of operator != int JazzStg::operator!=(JazzStg& c) { return stricmp(string, (char*) c) != 0 ? 1 : 0; } void main() { //--- create the sorted doublelist of JazzStg's called Too_Hip BI_SDoubleListImp Too_Hip; //-------- make some instances of JazzStg and pass in a string JazzStg A("Sun Ra"); JazzStg B("Ornette Coleman"); PRODUCT : Borland C++ NUMBER : 1734 VERSION : All OS : All DATE : October 25, 1993 PAGE : 3/3 TITLE : A BIDS example: BI_SDoubleListImp JazzStg C("John Coltrane"); JazzStg D("Roland Kirk"); //----------------- add the instancees for JazzStg to the list Too_Hip.add(A); Too_Hip.add(D); Too_Hip.add(B); Too_Hip.add(C); //------- define a list iterator to move through the list with BI_DoubleListIteratorImp next(Too_Hip); while (next) cout << (char*) next++ << "\n"; cout << endl; } DISCLAIMER: You have the right to use this technical information subject to the terms of the No-Nonsense License Statement that you received with the Borland product to which this information pertains.