Say I have:
class A
{
A()
{}
~A()
{}
};
class B
{
public:
B()
{}
~B()
{}
private:
static A mA;
};
B* pB = new B;
delete pB;
When I call delete pB, B’s destructor will be called. Will this then call the destructor for static member A?
The keyword static means that the variable is independent of instances. That’s why you can access static variables and methods without instantiating an object from the class in the first place. That’s why destroying an instance will not affect any static variables.