Setting value to dynamic class object

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.

And this is how I call it in the main()

1
2
Account* accountList[5];
accountList[stevilka-1]->resetPassword();


Thank you in advance
Last edited on
Nevermind, I realized that when testing this, I didnt initialize the array of classes.
Topic archived. No new replies allowed.