Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include "Factorial.h"
  2.  
  3.  
  4. //constructors
  5. Factorial::Factorial() {
  6.     Factorial(10);
  7. }
  8.  
  9.  
  10. Factorial::Factorial(int n) {
  11.     container_iterator_type it;
  12.     for (int i = 0; i < n; ++i) {
  13.         container.push_back(i);
  14.     }
  15.     for (it = container.begin(); it != container.end(); ++it) {
  16.         cout << *it << " ";
  17.     }
  18. }
  19.  
  20. Factorial::~Factorial() {}
  21.  
  22. container_iterator_type Factorial::begin() {
  23.     return container.begin();
  24. }
  25.  
  26. container_iterator_type Factorial::end() {
  27.     return container.end();
  28. }
  29. int Factorial::get_factorial(int num) {
  30.     if (num == 1) {
  31.         return 1;
  32.     } else {
  33.         return get_factorial(num - 1) * num;
  34.     }
  35. }
  36. void Factorial::operator()(container_iterator_type it) {
  37.     cout <<endl <<*it << "! = " << get_factorial(*it) << endl;
  38. }
  39.  
  40. void Factorial::operator*(container_iterator_type it) {
  41.     cout << endl << *it << "! = " << get_factorial(*it) << endl;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement