OOP and classes

Hello.

I want to make a simple "Number increaser app" with C++, i can choose how many numbers i want to increase in the app. i made a class for the increasing of the numbers, and i increase the numbers with random digits from 1 to 10.

i made a object array that stores the numbers but when i choose more than 1 number to increase the first number becomes a value between 1 and 10 but the second number becomes greater each time i press enter to increase again

example: the first number is 10 while the second is 20 or 15 when i press enter the first number is 13 while the second goes 34

what am i doing wrong?



here is the function in the class i call:


void Number::setNumber(int num)
{
this->num += num;

}

what i know this will add the random number to a new object element which is 0 by default, i might be wrong

Thanks
I don't understand what you are trying to do, can you rephrase your question?
Ok

i made a class which increases numbers in an object array with a random number from 1 to 10.

the thing is the second number can become over 10 from the very start

i can choose how many numbers i want to increase but if i choose more than 2 numbers to increase the rest will have the start value 20 or greater,

everytime i increase an number in the object array i call

void Number::setNumber(int num)
{
this->num += num;

}
Last edited on
Alright i solved this sorry :)
Topic archived. No new replies allowed.