Guest User

Untitled

a guest
Apr 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #include "Member.h"
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. static int totcount=0;
  6.  
  7. Member::Member(){
  8.  
  9. this->followers=0;
  10. this->following=0;
  11. totcount++;
  12. this->id=totcount;
  13.  
  14.  
  15.  
  16. }
  17. Member::~Member(){
  18. totcount--;
  19. this->following--;
  20.  
  21.  
  22.  
  23. }
  24. void Member::follow(Member& m){
  25. if(&m != this){
  26. if(check(m.id)==false){
  27. this->following++;
  28. Listfoll[m.id] = &m;
  29. m.followers++;
  30.  
  31. }
  32. }
  33. }
  34.  
  35.  
  36. void Member::unfollow(Member& m){
  37. if(&m != this){
  38. this->Listfoll.erase(m.id);
  39. this->following--;
  40. m.followers--;
  41. }
  42. }
  43.  
  44. int Member::numFollowers(){
  45. return this->followers;
  46. }
  47.  
  48. int Member::numFollowing(){
  49. return this->following;
  50. }
  51.  
  52. int Member::count(){
  53. return totcount;
  54. }
  55. bool Member:: check(int id){
  56. if(this->Listfoll.count(id)>0){
  57. return true;
  58. }
  59. return false;
  60. }
Add Comment
Please, Sign In to add comment