Based on "c++ primer", the type of a static data member can be the class type of which it is a member:
class Bar {
public:
// ...
private:
static Bar mem1; // ok
};
However, I have a hard time imagining a scenario in which such a feature is useful. I mean, why do you need a variable to be the class type? Can someone give me some examples? Thank you.
The only time that this would really be useful would be in implementing the "Singleton" pattern (or "Simpleton" to those of us who despise it).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With