?? candidatetype.h
字號:
#ifndef H_candidateType
#define H_candidateType
#include <string>
#include "personType.h"
const int NO_OF_REGIONS = 4;
class candidateType: public personType
{
public:
const candidateType& operator=(const candidateType&);
//Overload the assignment operator for objects of the
//type candidateType
const candidateType& operator=(const personType&);
//Overload the assignment operator for objects so that
//the value of an object of the type personType can be
//assigned to an object of type candidateType
void updateVotesByRegion(int region, int votes);
//Function to update the votes of a candidate for a
//particular region.
//Postcondition: Votes for the region specified by
// the parameter are updated by adding
// the votes specified by the parameter
// votes.
void setVotes(int region, int votes);
//Function to set the votes of a candidate for a
//particular region.
//Postcondition: Votes for the region specified by
// the parameter are set to the votes
// specified by the parameter votes.
void calculateTotalVotes();
//Function to calculate the total votes received by a
//candidate.
//Postcondition: The votes in each region are added
// and assigned to totalVotes.
int getTotalVotes() const;
//Function to return the total votes received by a
//candidate.
//Postcondition: The value of totalVotes is returned.
void printData() const;
//Function to output the candidate's name, the votes
//received in each region, and the total votes received.
candidateType();
//Default constructor.
//Postcondition: Candidate's name is initialized to
// blanks, the number of votes in each
// region, and the total votes are
// initialized to 0.
//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[NO_OF_REGIONS]; //array to store the
//votes received in
//each region
int totalVotes; //variable to store the total votes
};
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -