Hi I am learning C++ on my own, but i been having problems with the classes, can you give me a hand by telling me what can i do to get the output?
the output has to show the name, occupation, party and votes
Thank you for your help and time;
here's my code
------------------------------------------------------------------------------------------------Code:------------------------------------------------------------------------------------------------ class CCandidate { private: char m_strName[35]; char m_strOccupation[50]; //declaration of the variables that char m_strParty[50]; //will be used for each prototype int m_intVotes; char name [35]; char occupation [50]; char party[50]; int votes; public: CCandidate(); void setName(); //get name from user getName(char m_strName); void setOccupation(); getOccupation(char m_strOccupation); void setParty(); getParty(char m_strPary); clearVotes(); void recordVotes(); getVotes(int m_intVotes); }; //get data for each function CCandidate::setName() { char name[35]; //declaration of the variable cout<<"Please enter the candidate's name: "<<endl; //ask for candidate's name cin>>name; // the input is under the variable of name } CCandidate::setOccupation() { char occupation[50]; cout<<" Please enter the candidate's occupation: "<<endl; cin>>occupation; } CCandidate::setParty() { char party[50]; cout<<"Please enter the party of the candidate: "<<endl; cin>>party; } CCandidate::recordVotes() { int votes; cout<<"Please enter the amount of votes: "<<endl; cin>>votes; } // Outputs for the functions CCandidate::getName(char m_strName) { m_strName=name; //Substituting name to the variable m_strName for output cout<<" Candidate's name is:' "<<m_strName<<" ' "<<endl; } CCandidate::getOccupation(char m_strOccupation) { m_strOccupation=occupation; cout<<" The occupation of the candidate " <<m_strName<<" is "<<m_strOccupation<<endl; } CCandidate::getParty(char m_strParty) { m_strParty=party; cout<<" and the party he/she belongs is: "<<m_strParty<<endl; } CCandidate::clearVotes() { int m_intVotesCLR = 0; //sets the votes to 0 } CCandidate::getVotes(int m_intVotes) { votes=m_intVotes; cout<<" The candidate has "<<m_intVotes<<endl; } void main() { CCandidate.setName(); CCandidate.getName(); CCandidate.setOccupation(); CCandidate.getOccupation(); CCandidate.setParty(); CCandidate.getParty(): CCandidate.setVotes(); CCandidate.getVotes(); } }
Code tags added by Kermi3