#include#include // include VCL libraries using namespace std; int main() { TList* myList = new TList(); // create a new linked list myList->Add((void*)"John"); // add some elements to list myList->Add((void*)"Doe"); myList->Add((void*)"Mary"); for (int i = 0; i < myList->Count; i++) { // iterate through list and display elements cout << (char*)myList->Items[i] << endl; } delete myList; // free memory return 0; }
#includeThis example shows how TList can be used with custom objects. It creates a `Person` class with a `name` and `age` property. Three `Person` objects are created and added to a list. The program uses a loop to access each `Person` object in the list, casts it to the `Person` type, and displays their name and age. The memory is freed at the end of the program. In conclusion, TList is a container class in the Borland C++ Builder VCL package library that is used to create and manage linked lists in Windows development applications.#include // include VCL libraries using namespace std; class Person { public: string name; int age; Person(string n, int a) { name = n; age = a; } }; int main() { TList* personList = new TList(); Person* john = new Person("John", 30); Person* mary = new Person("Mary", 25); Person* jane = new Person("Jane", 35); personList->Add(john); personList->Add(mary); personList->Add(jane); for (int i = 0; i < personList->Count; i++) { Person* p = (Person*)personList->Items[i]; cout << p->name << " is " << p->age << " years old." << endl; } delete personList; delete john; delete mary; delete jane; return 0; }