Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- using namespace std;
- class Can{
- private:
- char name[100];
- int vote;
- public:
- static int totalVote;
- Can(){ }
- // Can(char *c, int in){
- // strcpy(name, c);
- // vote = in;
- // totalVote += in;
- // }
- double Par(){
- return (vote * 100) / totalVote;
- }
- void show(){
- cout << "Name -> " << name << '\n';
- cout << "Vote -> " << vote << '\n';
- cout << "Per -> " << Par() << '\n';
- }
- void setAll(){
- cout << "Name :";
- cin >> name;
- cout << "Vote :";
- cin >> vote;
- totalVote += vote;
- }
- };
- int Can :: totalVote = 0;
- int main(){
- //Can a("Fuad", 10);
- Can a[5];
- //a.show();
- for(int i = 0; i < 5; i++){
- a[i].setAll();
- }
- cout << "Total Vote :" << a[0].totalVote << '\n';
- for(int i = 0; i < 5; i++){
- a[i].show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement