Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Factorial.h"
- //constructors
- Factorial::Factorial() {
- Factorial(10);
- }
- Factorial::Factorial(int n) {
- container_iterator_type it;
- for (int i = 0; i < n; ++i) {
- container.push_back(i);
- }
- for (it = container.begin(); it != container.end(); ++it) {
- cout << *it << " ";
- }
- }
- Factorial::~Factorial() {}
- container_iterator_type Factorial::begin() {
- return container.begin();
- }
- container_iterator_type Factorial::end() {
- return container.end();
- }
- int Factorial::get_factorial(int num) {
- if (num == 1) {
- return 1;
- } else {
- return get_factorial(num - 1) * num;
- }
- }
- void Factorial::operator()(container_iterator_type it) {
- cout <<endl <<*it << "! = " << get_factorial(*it) << endl;
- }
- void Factorial::operator*(container_iterator_type it) {
- cout << endl << *it << "! = " << get_factorial(*it) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement