vendredi 20 mars 2020

Share auto-defined function in project

Please excuse this c++ newbie question. I want to share a function rnd() in a larger project. It is defined through:

#include<random>
#include<functional>

std::mt19937 generator (123);
std::uniform_real_distribution<double> dist(0.0, 1.0);
auto rnd = std::bind(dist,std::ref(generator));

I have tried putting the above definition in a header file, but get 'duplicate symbols' errors, and in a separate .cpp file which nets me 'undefined symbols' errors.

Aucun commentaire:

Enregistrer un commentaire