|
Re: Help Needed with Function Reference Variables (C++)
Your divisors[] array is too small, you declare it to hold 6 double values but you try to use 7 elements, number 0 is the first, number 6 is the seventh.
What is the point of the function? In its current form it only tries to return the 7th element in the array (a single double value). If you wish to return the whole array, either pass a double pointer to some array as an argument to the function, or change the return type to double* and malloc some storage for your newly created array.
The arguments as reference make no sense in this context since you are not modifying them, but this is just a sample code to illustrate the point where the error happens, right?
There are much nicer container types available in C++, may I suggest you look past simple arrays.
__________________
My posts are a work of fiction. Everything I write is an opinion, a joke, or both. Do not follow my advice.
F14: Dell Latitude D630 Core2Duo 2GHz 4GB
F14 x64: HP i7 3GHz 12GB
#317797
Last edited by pforsell; 5th April 2011 at 03:42 PM.
|