Daanial Ahmad
Daanial Ahmad

Reputation: 11

Random Number Generation via Linear Congruential Generators in C++

I am studying random number generation in C++ and I had implemented it from the following site:

https://www.quantstart.com/articles/Random-Number-Generation-via-Linear-Congruential-Generators-in-C/

When running this program, I am getting the following error:

main.cpp:12:31: error: cannot declare variable ‘lcg’ to be of abstract type ‘LinearCongruentialGenerator’
   12 |   LinearCongruentialGenerator lcg(num_draws, init_seed);
      |                               ^~~
In file included from main.cpp:2:
lin_con_gen.h:6:7: note:   because the following virtual functions are pure within ‘LinearCongruentialGenerator’:
    6 | class LinearCongruentialGenerator : public RandomNumberGenerator
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from lin_con_gen.h:4,
                 from main.cpp:2:
random.h:30:18: note:   ‘virtual void RandomNumberGenerator::get_uniform_draws(std::vector&)’
   30 |     virtual void get_uniform_draws(std::vector<double>& draws) = 0;
      |                  ^~~~~~~~~~~~~~~~~
lin_con_gen.cpp:51:6: error: no declaration matches ‘void LinearCongruentialGenerator::get_unifrom_draws(std::vector&)’
   51 | void LinearCongruentialGenerator::get_unifrom_draws(std::vector<double>&draws)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~
lin_con_gen.cpp:51:6: note: no functions named ‘void LinearCongruentialGenerator::get_unifrom_draws(std::vector&)’
In file included from lin_con_gen.cpp:4:
lin_con_gen.h:6:7: note: ‘class LinearCongruentialGenerator’ defined here
    6 | class LinearCongruentialGenerator : public RandomNumberGenerator
      |

Please kindly help me in running it correctly.

Upvotes: 1

Views: 153

Answers (0)

Related Questions