I'm trying to get a pointer to a function of an instance of my object. Here is my code:
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
class Dice {
int face;
public:
Dice () {
face = rand() % 6 + 1;
}
int roll() {
face = rand() % 6 + 1;
return face;
}
};
int main()
{
Dice mydice;
vector<int> v(1000);
generate(v.begin(),v.end(),mydice.roll);
}
My compiler barks at me at the generate line with cryptic messages =) Please point out how to properly tell generate to call mydice.roll()
to populate vector v
.