I'm trying to static count my driver user. however it always give me same value instead
class Driver {
private:
static int ID;
string name;
public :
void displayDriver(string n) {
cout << ID << endl;
}
void createDriver(string n) {
name = n ;
ID++;
}
}
int Driver::id=0;
int main() {
Driver driver[10];
Driver[0].createDriver("first");
Driver[1].createDriver("second");
Driver[2].createDriver("first");
Driver[0].displayDriver();
Driver[1].displayDriver();
Driver[2].displayDriver();
}
my expected output should be :
1
2
3
but system shows me :
3
3
3