Numbers game

hello,

I have a program that stores current a low numbers. The Object is to Store the low number every time time one is presented. so say I start the function the first number is the low number. but the trouble im having it once the function is called again it starts over(low number). Is there a way I can keep the function value once the function is called again? or does anyone know a better way of doing this while keeping function in a class?

Thanks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
double a;

class rff{ 

public:
void FGH()
{
		double	b=0;

	cout<< "pick a number"<<endl;
	cin>>a;
b=a;
	cout << "yournum";
		cout << "LAST num:" << a<< endl;
		cout << "Low num:" << b << endl;

   cout <<"'pick another number"<<endl;
cin>>a;
		if (a < b)
		{
			b = a;
		}
		cout << "yournum";
		cout << "LAST num:" <<a<< endl;
		cout << "Low num:" << b<< endl;
		cin.get();
}

};





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int main(){



	rff ws;
   ws.FGH();

     ws.FGH();
	   ws.FGH();


	cin.get();
	cin.get();
	return 0;
}
Last edited on
If you have b = a going on then there is hardly much point checking if a or b are higher or lower than each other. You want a user to enter a number, a, then check if a is < b and if and only if a is less than b do b = a;
Topic archived. No new replies allowed.