📄 candidatetype.h
字号:
#ifndef H_candidateType
#define H_candidateType
#include <string>
#include "personType.h"
using namespace std;
const int noOfRegions = 4;
class candidateType: public personType
{
public:
const candidateType& operator=(const candidateType&);
//Overload the assignment operator for the objects of the
//type candidateType.
const candidateType& operator=(const personType&);
//Overload the assignment operator for the objects so
//that the value of an object of the type personType can
//be assigned to an object of the type candidateType.
void setVotes(int region, int votes);
//Function to set the votes of a candidate for a
//particular region.
//Postcondition: The votes specified by the parameter votes
// are assigned to the region specified by the
// parameter region.
void updateVotesByRegion(int region, int votes);
//Function to update the votes of a candidate for a
//particular region.
//Postcondition: The votes specified by the parameter votes
// are added to the region specified by the
// parameter region.
void calculateTotalVotes();
//Function to calculate the total votes received by a
//candidate.
//Postcondition: The votes received in each region are added.
int getTotalVotes();
//Function to return the total votes received by a
//candidate.
//Postcondition: The total votes received by the candidate
// are returned.
void printData() const;
//Function to output the candidate抯 name, the votes
//received in each region, and the total votes received.
candidateType();
//default constructor
//Postcondition: Initialize the votes received in each
// region, and the total votes received, to zero.
//Overload the relational operators.
bool operator==(const candidateType& right) const;
bool operator!=(const candidateType& right) const;
bool operator<=(const candidateType& right) const;
bool operator<(const candidateType& right) const;
bool operator>=(const candidateType& right) const;
bool operator>(const candidateType& right) const;
private:
int votesByRegion[noOfRegions];
int totalVotes;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -