【发布时间】:2013-10-10 22:02:18
【问题描述】:
我目前正在从事 C++ 学校作业,我有 3 种对象类型。客户、租用和旅游。客户喜欢参观和雇用。要求是根据用户对数据结构类型的选择,使用 Array、Vector、Map 和 List 来保存这些信息。有包含 1000 条记录的数据文件,应用程序将读取它们并创建必要的对象。例如,如果用户选择向量,它将创建 3 个包含上述对象的向量。然后会对它们进行以下操作。
- 加载我们为您提供的大型数据集。如果 您使用的数据结构支持排序,它应该按 描述。
- 准备已预订旅行的客户列表 年底前
- 准备欠我们超过 2000 美元,按帐户到期日期排序
- 为邮政编码以 5 开头的客户准备一份招聘清单
我的主应用程序头文件中有以下内容。
私人:
string structureType;
Customer** customerListArray;
Tour** tourListArray;
EquipmentHire** equipmentsListArray;
vector<Customer *> customerListVector;
vector<Tour *> tourListVector;
vector<EquipmentHire *> equipmentsListVector;
std::map<string, Customer*> customerListMap;
std::map<string, Tour*> tourListMap;
std::map<string, EquipmentHire*> equipmentsListMap;
list<Customer *> customerListList;
list<Tour *> tourListList;
list<EquipmentHire *> equipmentsListList;
然后我根据用户的选择将数据加载到这些对象上。但是我的问题是,我是否需要为每种类型的数据结构编写不同的函数来执行上述操作,或者是否有一个通用接口可以用于所有这些操作?
我的C++知识非常有限,要求是使用C++98。
谢谢。
【问题讨论】:
标签: c++ arrays list vector map