dynamic array in sub-subclass

i can see the array in my subclass, but not my sub-subclass. im working on another project and it took me a while to find out that this was the problem...please tell me how to declare this/ where to look to find out.

it compiles but during the run it stops on "signal 11" under eclipse. using the debugger, it was outputting a large number

#include <iostream>
using namespace std;
class myFunc{
public:
myFunc();
void subclass(int* array);
void subsubclass();
private:
int* array;
};
myFunc::myFunc(){
};

void myFunc::subsubclass(){
for (int i=0; i < 10; i++){
cout<<array[i];
}
};

void myFunc::subclass(int* array){
subsubclass();
};

int main()
{
int b[10];
for( int i= 0; i < 10; i++){
b[i]=i;
}
myFunc mf;
mf.subclass(b);
}
your subclass function is receiving a pointer that is also called array, this is a different "array" from your array member. It should use a different name, and then assign that variable to array.
thanks, u were right, when i put

void myFunc::subclass(int* arr){
array=arr;
subsubclass();
};

everything worked out great
Topic archived. No new replies allowed.