Progression Library 0.0.1
A header only arithmetic, geometric and fibonacci progression library
Loading...
Searching...
No Matches
Progression Class Referenceabstract

A header only c++ progression library. More...

#include <progression.hpp>

Inheritance diagram for Progression:
Inheritance graph
Collaboration diagram for Progression:
Collaboration graph

Public Member Functions

virtual long first_value ()
 Resets the progression and returns the first value.
virtual long next_value ()=0
 Advances to and returns the next value in the progression.
void print_progression (int n)
 Prints the first n terms of the progression.
virtual ~Progression ()=default
 Virtual destructor to allow proper cleanup of derived objects.

Protected Attributes

long curr
 Current value in the progression.
long first
 First value of the progression.

Detailed Description

A header only c++ progression library.

Author
Magpiny BO
Date
15 December 2025
Warning
Ensure proper memory management while using this library
Note
This library implements arithmetic, geometric and fibonacci progressions only

Basic Usage

#include "progression.hpp"
int main(){
Progression *ap = new ArithProgression(2, 3);
delete ap;
return EXIT_SUCCESS;
}
Arithmetic progression: each term is obtained by adding a fixed increment.
Definition progression.hpp:83
A header only c++ progression library.
Definition progression.hpp:40
void print_progression(int n)
Prints the first n terms of the progression.
Definition progression.hpp:187

Abstract base class representing a generic numeric progression.

This class defines the common interface for all progressions. It cannot be instantiated directly because next_value() is pure virtual. Derived classes must implement their specific way of advancing to the next term.

Member Function Documentation

◆ first_value()

long Progression::first_value ( )
virtual

Resets the progression and returns the first value.

This function is called at the beginning of print_progression() to ensure the sequence starts from the beginning.

Returns
The first value in the progression.

Reimplemented in FibonacciPg.

Here is the caller graph for this function:

◆ next_value()

virtual long Progression::next_value ( )
pure virtual

Advances to and returns the next value in the progression.

This is a pure virtual function – derived classes must provide their own implementation.

Returns
The next value in the sequence.

Implemented in ArithProgression, FibonacciPg, and GeometricProgression.

Here is the caller graph for this function:

◆ print_progression()

void Progression::print_progression ( int n)

Prints the first n terms of the progression.

The output is space-separated on a single line followed by a newline.

Parameters
nNumber of terms to print (n ≥ 1).
Here is the call graph for this function:

The documentation for this class was generated from the following file: