Hello, so I am playing around with classes and I pretty much understand them apart from the fact how do you set a value to dynamic class object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
void Account::resetPassword() {
char c;
int r;
int num = rand() % 3 + 6;
string passwordGenerated;
for(int i = 0; i < num; i++){
r = rand() % 26;// generate a random number
c = 'a' + r;
int rand1 = rand() % 2;
if(rand1 == 1){
c = toupper(c);
}
passwordGenerated += c;
}
password = passwordGenerated;
}
This is my code for the method in class, it generates random password. When I have static class object in the main program it works, but when I use pointer and try to use that code it crashes. I tried many things like this->password = passwordGenerated;
but that didnt work either.