Advertisement
Guest User

HEAVY_POOPERS

a guest
Sep 30th, 2016
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. /// ###### MAIN.CXX ######
  2. #include "poop.h"
  3.  
  4. #include <cstdio>
  5.  
  6. int main(int argc, char **argv) {
  7.     using namespace Water;
  8.  
  9.     Poop firstPoop;
  10.     Poop secondPoop;
  11.    
  12.     firstPoop.setPoopValue(10);
  13.     secondPoop.setPoopValue(20);
  14.  
  15.     Poop poop = firstPoop + secondPoop;
  16.  
  17.     printf("I've just pooped %d times\n", poop.poopValue());
  18.     return 0;
  19. }
  20.  
  21.  
  22. /// ###### POOP.H ######
  23. #ifndef CLS_H
  24. #define CLS_H
  25.  
  26. namespace Water {
  27.  
  28. class Poop {
  29. public:
  30.     friend Poop operator+(const Poop &, const Poop &);
  31.  
  32.  
  33.     Poop();
  34.  
  35.     ~Poop();
  36.  
  37.     int poopValue() const;
  38.  
  39.     void setPoopValue(const int v);
  40.  
  41. private:
  42.     int m_poopVariable;
  43. };
  44.  
  45. Poop operator+(const Poop &first, const Poop &second);
  46.  
  47. };
  48.  
  49. #endif // CLS_H
  50.  
  51.  
  52. /// ###### POOP.CXX ######
  53. #include "poop.h"
  54.  
  55. #include <cstdio>
  56.  
  57. Water::Poop::Poop() : m_poopVariable(0) {
  58.  
  59. }
  60.  
  61. Water::Poop::~Poop() {
  62.     printf("Poop sinks with score %d\n", m_poopVariable);
  63. }
  64.  
  65. void Water::Poop::setPoopValue(const int v) {
  66.     m_poopVariable = v;
  67. }
  68.  
  69. int Water::Poop::poopValue() const {
  70.     return m_poopVariable;
  71. }
  72.  
  73. Water::Poop Water::operator+(const Poop &first, const Poop &second) {
  74.     Poop third;
  75.     third.m_poopVariable = first.m_poopVariable + second.m_poopVariable;
  76.     return third;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement