#include <iostream>
class A {
public:
const int HP = 200;
A(){
std::cout << this->HP << std::endl;
}
};
class B : public A {
public:
B();
};
Constructing a B
object will construct the A
potion first.
I expect to reinitialize HP
so that B()
can print new HP
.
Is this feasible for a base class const
member ?
I need a member shared between base and child but to be constant in one instance of class, any suggestions?