im getting this funny error ive never seen before. the class is taking objects in an array from another class and storing them in a sub array specificed by the user ..... any thing will help
thnanks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
// main menu call to class
sublist[100] = aList.sublist(start, finish, success);
List List::sublist(int fromIndex, int upToIndex, bool& success)
{
List subList;
int counter = 1;
for (int i = fromIndex - 1; i < upToIndex; i++)
{
subList.insert(counter, items[i], success);
counter ++;
cout << "adding...";
}
cout << "after";
return subList;
}
2 [main] listlab 2872 _cygtls::handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
3780 [main] listlab 2872 open_stackdumpfile: Dumping stack trace to listlab.exe.stackdump
adding...adding...adding...adding...after
RUN FAILED (exit value 35,584, total time: 11s)
Hard to spot the error with just the code you posted... but here are some thoughts:
line 2) does 'sublist' have at least 101 elements? Is [100] a valid index? or is that out of bounds?
lines 10, 12) you're doing items[i], but i will start at fromindex-1. So if you make a sublist fromIndex 0, you're actually accessing index [-1] (bad!). Why are you subtracting 1 there?
sublist has no more then 8 elements so i know there are enough memory spaces, and as for the -1 i dont know i got rid of it and get the same error ....
the problem is when it trys to return the list because the cout statemets make it through the loop but do not make it out of the method
THANK YOU ...... ya i dont know why i had my sublist as an array .... the list class has an array private variable i was supposed to be using ... that fixed everything thank you