/* * File: main.cpp * Author: engineer * * Created on February 14, 2010, 1:06 AM */ // std #include #include // boost #include typedef boost::lagged_fibonacci607 rand_gen; class Foo{ private: double x; static rand_gen rng; public: // default constructor Foo() { x = 0.; }; // copy constructor Foo(const Foo& c) { this->x = c.x; }; // destructor ~Foo() {}; // assignment operators Foo& operator=(Foo& a) { if (this != &a) { this->x = a.x; } return *this; }; Foo& operator=(const Foo& a) { if (this != &a) { this->x = a.x; } return *this; }; void drive(unsigned end) { for(unsigned i = 0; i < end; ++i) { Foo other = *this; std::cout << "'other' object:" << std::endl; other.usage(5); std::cout << "'this' object:" << std::endl; this->usage(5); } }; void usage(unsigned end) { boost::uniform_01 noise_gen(Foo::rng); for(unsigned i = 0; i < end; ++i) { std::cout << noise_gen() << " "; } std::cout << std::endl; }; static void set_seed(unsigned seeed) { Foo::rng.seed(seeed); }; static void print_state() { std::cout << Foo::rng << std::endl; }; }; rand_gen Foo::rng; int main(int argc, char** argv) { Foo::set_seed(RAND_MAX); //Foo::print_state(); Foo one; one.drive(3); return (EXIT_SUCCESS); }