I am learning C++ and I can't seem to find an answer to my issue. When I run my code, I don't get any compiler errors, but I when I call a function "getVin()" (supposed to generate a random number with the use of "generate()" function) it doesn't do so. It outputs a zero. Here is my class (from header file):
class Vehicle {
public:
Vehicle();
static int generate();
const int getVin () { return m_vin; }
protected:
float m_lla[3];
const int m_vin = s_idgen;
private:
static int s_idgen;
};
And definition (from source file):
int Vehicle::s_idgen = generate();
Vehicle::Vehicle() {
m_lla[3] = 0;
}
int Vehicle::generate() {
srand((int)time(0));
return (rand() % 10000) + 1;
}
Any advice would be helpful, thank you!