I would do something like that:
Code:
class A {
public:
A(int n = 0) : n(n) {}
~A() {}
int GetN() { return n; }
void SetN(int n) { this->n = n; }
private:
int n;
};
class B : public A {
public:
B() : A(0) {}
~B() {}
};
// A protected interface would have been
class A {
public:
A(int n = 0) : n(n), m(0) {}
~A() {}
// Accessors, n is publicly accessible
int GetN() { return n; }
void SetN(int n) { this->n = n; }
protected:
// You can construct an object with an initialized m member in your derived class
A(int n = 0, int m = 0) : n(n), m(m) {}
// Accessors, m is accessible by the derived classes
int GetM() { return m; }
void SetM(int m) { this->m = m; }
private:
int n;
int m;
};
class B : public A {
public:
B(int m) : A(0, m) {}
~B() {}
};