Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/161.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 有人能帮我上这门课吗?_C++_Class_Std - Fatal编程技术网

C++ 有人能帮我上这门课吗?

C++ 有人能帮我上这门课吗?,c++,class,std,C++,Class,Std,为了确保每个人都理解我的问题,我将在这里发布整个问题。 在编程示例Election Results中,对象candidateList 声明orderedArrayListType类型的,以处理投票 数据。插入候选人数据并更新和删除数据的操作 找回选票有点复杂。更新 候选人的选票,我们从候选人名单中复制每个候选人的数据 在candidateType类型的临时对象中,更新 临时对象,然后用 临时对象。这是因为数据成员的列表是 候选名单的受保护成员,列表的每个组成部分都是 私有数据成员 在本实验室中,

为了确保每个人都理解我的问题,我将在这里发布整个问题。

在编程示例Election Results中,对象candidateList 声明orderedArrayListType类型的,以处理投票 数据。插入候选人数据并更新和删除数据的操作 找回选票有点复杂。更新 候选人的选票,我们从候选人名单中复制每个候选人的数据 在candidateType类型的临时对象中,更新 临时对象,然后用 临时对象。这是因为数据成员的列表是 候选名单的受保护成员,列表的每个组成部分都是 私有数据成员

在本实验室中,您将修改编程示例 简化候选人数据访问的结果如下:

从orderedArrayListType类派生类candidateListType

class candidateListType:public orderedArrayListType{
公众:
candidateListType();//默认构造函数candidateListType(int)
大小);//构造函数
无效进程投票(字符串fName、字符串lName、整数区域、整数投票);
//用于更新特定候选人的投票数的函数
对于特定地区//后置条件:候选人的姓名,
区域、//和投票数作为参数传递。
void addvoices();//用于查找收到的投票总数的函数
每位候选人。
void printResult()const;//用于输出投票数据的函数。};
因为类candidateListType是从该类派生的 OrderedArrayList类型,列表是该类的受保护数据成员 orderedArrayListType(从类arrayListType继承),列表 可由candidateListType类的成员直接访问

编写类的成员函数的定义 候选名单类型。使用类重写并运行程序 候选名单类型

这就是全部问题所在。经过一些帮助,我已经完成了candidateListType类:

candidateListType:
class candidateListType: public orderedArrayListType
{
public:
candidateListType(); //default constructor
candidateListType(int size); //constructor
void processVotes(string fName, string lName, int region, int votes);
//Function to update the number of votes for a
//particular candidate for a particular region.
//Postcondition: The name of the candidate, the region,
//and the number of votes are passed as parameters.
void addVotes();
//Function to find the total number of votes received by
//each candidate.
void printResult() const;
//Function to output the voting data.
orderedArrayListType<candidateType>& cList;
std::orderedArrayListType<candidateType>::iterator it;

//default constructor
candidateListType :: candidateListType(){
cList = new orderedArrayListType<candidateType>(100);
}

//constructor
candidateListType :: candidateListType(int size){
cList = new orderedArrayListType<candidateType>(size);
}

//processing votes...storing objects
candidateListType :: void processVotes(string fName, string lName, int region, int votes){
candidateType temp;
temp.setName(fName,lName);
temp.setVotes(region,votes);
it = orderedArrayListType.end();
orderedArrayListType.insert(it,temp);
}
//priting total votes data
candidateListType :: void addVotes(){
for (it=orderedArrayListType.begin(); it!=orderedArrayListType.end(); ++it){
cout<<*it.printData();
}
}

//printing results

candidateListType :: void printResult(){
candidateListType temp;
int largestVotes = 0;
int sumVotes = 0;
int winLoc = 0;
int NO_OF_CANDIDATES = orderedArrayListType.end();
for (int i = 0; i < NO_OF_CANDIDATES; i++)
{
orderedArrayListType.retrieveAt(i,temp);
temp.printData();

sumVotes += temp.getTotalVotes();

if (largestVotes < temp.getTotalVotes())
{
largestVotes = temp.getTotalVotes();
winLoc = i;
}
}

orderedArrayListType.retrieveAt(winLoc,temp);
cout << endl << endl << "Winner: ";

string firstN;
string lastN;

cout << temp.getFirstName() << " " << temp.getLastName();
cout << ", Votes Received: " << temp.getTotalVotes() << endl << endl;
cout << "Total votes polled: " << sumVotes << endl;
}

};
候选列表类型:
类candidateListType:PublicOrderedArrayListType
{
公众:
candidateListType();//默认构造函数
candidateListType(int size);//构造函数
无效进程投票(字符串fName、字符串lName、整数区域、整数投票);
//函数用于更新某个项目的投票数
//特定地区的特定候选人。
//后置条件:候选人的姓名、地区、,
//投票数作为参数通过。
无效投票();
//函数用于查找用户收到的投票总数
//每个候选人。
void printResult()常量;
//函数输出投票数据。
OrderedArrayList类型和cList;
std::orderedArrayListType::iterator;
//默认构造函数
candidateListType::candidateListType(){
cList=新的OrderedArrayList类型(100);
}
//建造师
candidateListType::candidateListType(整数大小){
cList=新的OrderedArrayList类型(大小);
}
//处理投票…存储对象
candidateListType::void进程投票(字符串fName、字符串lName、整数区域、整数投票){
假丝酵母型;
临时设置名称(fName,lName);
临时设置投票(地区、投票);
it=orderedArrayListType.end();
orderedArrayListType.insert(it,temp);
}
//计票总票数数据
candidateListType::void addVotes(){
对于(it=OrderedArrayList.begin();it!=OrderedArrayList.end();+it){
cout
std::orderedArrayListType::iterator;
您的自定义代码不是标准名称空间的一部分(或者至少不应该是),因此请删除名称空间前缀以进行读取

orderedArrayListType<candidateType>::iterator it;
orderedArrayListType::迭代器;
或者,如果您有自定义名称空间

your_namespace_here::orderedArrayListType<candidateType>::iterator it;
your_namespace_here::orderedArrayListType::iterator;

欢迎使用SO.Fair info,没有人会费心下载文件。还要注意的是,您的代码没有缩进是不可读的。如何定义
orderedArrayListType
呢?无论它是以何种方式定义的,它肯定不在
std
命名空间中。因此出现了错误。请仔细查看cal11.cpp源代码的第24行您好,谢谢您的帮助,但是在我删除“std::”之后,它仍然有错误。
orderedArrayListType<candidateType>::iterator it;
your_namespace_here::orderedArrayListType<candidateType>::iterator it;