> On May 28, 6:11 pm, Devon Null <theronnights
@xgmailx.com> wrote:
> > desktop wrote:
> > > I have this class:
> > > class MyArray {
> > > public:
> > > MyArray(int a) : data(new int[a]){}
> > > ~MyArray() {delete[] data;}
> > > int& operator()(int a){
> > > return data[a];
> > > }
> > > int operator()(int a) const{
> > > return data[a];
> > > }
> > > private:
> > > int* data;
> > > };
> > > int main() {
> > > MyArray myarr(5);
> > > return 0;
> > > }
> > > But when are the destructor called?
> > The destructor is called implicitly when the object is distroyed - how
> > it is destroyed does not matter.
> btw, you can invoke destructor explicitly:
and you can also jump off a skyscraper without a parachute.