EDIT: I have found the error: I did not initialize an array with a size. question can be closed.
I have a class V
, and another class N
. An object of N
will have an array of pointers to objects of class V
(say V **vList
). So, N
has a function like
V **getList();
Now in some function of other classes or simply a driver function, if I say V **theList = (N)n.getList();
Q1: theList
would be pointing at the 1st element of the array? Given that the size of array is known, can I loop through with index i
and say V *oneV = *vList[i]
? Please correct me if what I'm doing above is wrong.
I have been using debugger to trace through the whole process of my program running, the thing I found was that after using V *oneV = vList[i]
, the value of the pointers in the array, vList
, were the same as when they were created, but if I follow the pointer to where it is pointing at, the object was gone. I'm guessing that might be the reason why I am getting seg fault or bus error. Could it be the case? WHY did I 'loose' the object at the other end of a pointer? What did I do wrong?
and yes, I am working on a school assignment, that's why I do not want to print out my codes, I want to finish it myself, but I need help finding a problem. I think I still need explanation on array of pointers. Thank you