My code looks something like this:
namespace N {
class C {
public:
void function1() {
// code
}
void function2() {
// code
}
C(int length) {
int array[length] = {}
}
}
}
How should I make the array
visible to other parts of the class (e.g. function1
and function2
) without making it a global variable? I can't declare the variable in the private part of the class because I need to set the length according to the constructor input while the variable is being declared.