I have s simple question:
Situation:
When I rightclick Source Files folder and select Add->Class – C++ class ,
a class is added in a separate file *.cpp and *.h (great! This is exactly what I wanted).
Now: what does the function name
classname::~classname(void)
exactly does ?
Is it a destructor of that class called “classname” ?
I cannot find explanation of this syntax “::~” on the internet, and so I am asking here. 🙂
There are two different things at work here:
::~classname.In your case, the syntax
classname::~classname(void)simply defines the class’ destructor. The::means that what follows belongs to the class calledclassname. And what follows is just the destructor name (see above).This is the same syntax used for all class member definitions. If your class had a function called
foothat took anintand returned anint, then its definition outside the class would look as follows:This is exactly the same as with the destructor (except that the destructor has no return value and takes no arguments).