1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
class Quote
{ string date;
float price;
int volume;
....
};
class Stock
{ string symbol;
string fullname;
map<string, Quote> quotes; // Indexed by date
public:
Stock (string sym, string name);
void AddQuote (string date, float price, int vol)
{ Quote q (date, price, vol);
quotes.insert (pair<string,Quote>(date, q));
}
...
};
map<string,stock> stocks; // Indexed by stock name
Stock yahoo ("YHOO", "Yahoo");
yahoo.AddQuote ("05/31", 30.00, 1000000);
yahoo.AddQuote ("05/02", 29.00, 900000);
stocks.insert (pair<string,Stock> ("YHOO", yahoo);
|