- Each declaration calls class constructor
- Destructor called when object goes out of scope
- Destructor call is implicit and automatic
// client code
{ // begin block
...
IntArray A (1000, -1);
IntArray B (100);
IntArray C;
...
} // end block
|
class IntArray
{
public:
IntArray (size_t sz = 10, int ivalue = 0);
~IntArray ();
// more later
private:
size_t size_;
int * data_;
}
IntArray::~IntArray ()
{
delete [] data_;
}
|