Finding the size of an Array?

Apr 3, 2012 at 3:20pm
If given the constraints thatthe array will be between 1 and 50 elements. The array is in class where the object is initialized with an array of elements within that range. How do i know how big the array is?
Apr 3, 2012 at 3:22pm
You don't really. If it's a static instance of a standard C++ array then the size is hard-coded.

I guess all you could do is initialise the maximum value of 50 elements.
Last edited on Apr 3, 2012 at 3:23pm
Apr 3, 2012 at 3:30pm
The maximum value of each element is set as 5000. The problem is that the class is for a betting game. The array int amounts is initialized with dollar amount bets on the margin of victory. {10,20,30} means that the zeroth element of 10 equals a $10 bet on a draw. $20 on a win by one point and $30 on a margin of 2. The method arguments include finalResult which is 0 to n-1 where n is the number of elements of in the amounts array.

The issue I'm thinking about is that I have to add all of the non winning bet amounts from the array to a houseSum total.
Apr 3, 2012 at 3:45pm
intialize the entirre array to a default value then load the array and search for the default value incrementing a size counter each time its not found.

Kind of a waste of time though
Topic archived. No new replies allowed.