I've made my program running, but as soon as I try to create my object, it crashes.
It looks something like this (of course I'm writing just the most important, they're separated well and the files are included correctly, otherwise it wouldn't run):
//A.h
Class A {
protected:
string something;
private:
A();
};
//A.cpp
A::A() {
something = "hi";
}
//B.h
Class B: public A {
protected:
int n;
int** array;
public:
B();
};
//B.cpp
B::B(): A() {
n = 8;
array = new int*[n];
for (int i = 0; i<n; i++) {
array[n] = new int[n];
}
for (int i = 0; i<n; i++) {
for (int j = 0; j<n; j++) {
array[i][j] = 0;
}
}
}
//C.h
class C: public B {
protected:
int v1;
int v2;
private:
C();
};
int main() {
C Myobject;
return 0;
}
I put the hello world part to know where the problem is, the program crashes before that, so it's probably a problem with inheritance. Any help is appreciated.