If you want to store object/structs of your own, try the CArray template class. Or you can store pointers to your items in CPtrArray. Or derive from CObject and use CObArray. Or derive a CTypePtrArray class. I suggest you read the MSDN sections about collection classes (there's a lot of them). Personally though I'd use the STL classes. Here's how you can do it in STL:
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>
using namespace std;
typedef string TKey;
struct TRecord
{
TKey key;
int data;
bool operator== (const TRecord& tdr) const {return key == tdr.key;}
bool operator< (const TRecord& tdr) const {return key < tdr.key;}
};
typedef vector<TRecord> tvtd;
// vector write -> stdout
void output(tvtd vstruct)
{
for(tvtd::iterator il = vstruct.begin(); il!=vstruct.end(); il++) cout << (*il).key << endl;
cout << "******************" << endl;
}
int main(int argc, char* argv[])
{
tvtd vstruct;
TRecord td;
tvtd::iterator il, il1;
td.key = "Hi there13"; // Insert at end
vstruct.push_back(td);
td.key = "Hi there17"; // Insert at end
vstruct.push_back(td);
td.key = "Hi there04";
il1 = vstruct.insert(vstruct.end(),td); // Insert at end (save pointer)
td.key = "Hi there22";
vstruct.insert(vstruct.begin(),td); // Insert at start
// vector write -> stdout
output(vstruct);
// Find
il = find(vstruct.begin(),vstruct.end(),td); // Find "Hi there22"
cout << (*il).key << endl; // Check correct Element
cout << "******************" << endl;
vstruct.erase(il); // "Hi there22" delete
vstruct.erase(il1); // "Hi there04" delete
// vector write -> stdout
output(vstruct);
// Noch einige Elemente hinzufügen
td.key = "Hi there14"; // Insert at end
vstruct.push_back(td);
td.key = "Hi there05";
vstruct.insert(vstruct.end(),td); // Insert at end
td.key = "Hi there19";
vstruct.insert(vstruct.begin(),td); // Insert at start
// vector write -> stdout
output(vstruct);
// vector sortieren
sort(vstruct.begin(),vstruct.end());
// vector write -> stdout
output(vstruct);
return 0;
}
This creates a vector of CRecords and does some stuff with it.
The operator overloads in the record struct are needed for operations like find and sort. If you don't need these, you don't need the operators. If you need MFC serialisation, you could add that pretty easily too, I would guess.

I just can't help it, I like MS...
