Thanks laserlight, maven and everyone else for their suggestions. My program is working like a charm now.
Thanks laserlight, maven and everyone else for their suggestions. My program is working like a charm now.
andrewmills, don't use casts. Especially not when you don't know when to use them.
And when you are a beginner, don't use C-style casts. They can do more than you know (as you've just found out).
If you are writing good C++ code, then chances that you need casts are slim. Avoid them. Then you know you aren't doing some terrible mistake the compiler is telling you to avoid.
Hi forum. I have another question regarding this program. Now, as a a part of the program, I am supposed to calculate the maximum and minimum value of "seismic size", " air temperature" and "ground temperature". One way to do this, whic I know how to do, is calculating maximum and minimum values for each quantity separately. However, that is going to make the code awfully long. So, I was wondering if there is another short and more efficient way of doing this. My idea is to creat a function that lays out the fundamental way of calculating the maximum and minimum value and maybe we could transfer other functions -GetSeismicSize(), GetAirTemp, GetGroundTemp- as parameters into this function and thus, calculate maximum and minimum value of each quantity. But, again it is just my idea. If this is to happen, we should be able to create a function with another function as a parameter. And, I am not sure if it possible to do this or not.
Yes, it is possible to create a function that has a function pointer as a parameter. You may also want to look into Functors. Here is another page about function pointers and functors that may be of some help.
Jim