I have a class:
class Nothing
{
/// Constructor, Destructor, Copy and Assignment
public:
Nothing();
~Nothing();
Nothing(const Nothing& clone);
/// Operators
const Nothing& operator=(const Nothing& other);
/// Static Members
private:
static unsigned long long id_counter;
static unsigned long long instance_counter;
};
Nothing::Nothing()
{
m_name.clear();
id_counter ++;
m_id = id_counter;
instance_counter ++;
}
Nothing::~Nothing()
{
m_name.clear();
instance_counter --;
}
Nothing::Nothing(const Nothing& other)
{
}
unsigned long long Nothing::id_counter = 0;
unsigned long long Nothing::instance_counter = 0;
Notice I am using unsigned long long to count instances of the class. Should I use std::size_t instead?
As an aside: If I have an instance of a class, and I do something like this:
Nothing instance;
instance(Nothing()); // Calling copy constructor
Will the destructor be called before the copy constructor is called? Reason for asking is do I need id_counter ++;
and instance_counter ++;
inside of my copy constructor?