Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Someone knows how can I destroy a 3D vector? (http://www.velocityreviews.com/forums/t288135-someone-knows-how-can-i-destroy-a-3d-vector.html)

joseantonio 01-13-2005 10:06 AM

Someone knows how can I destroy a 3D vector?
 
Hi all,

I am novice in C++, (basically, novice using OOP). I am developing an
application where I use a vector 3D defined as

vector< vector< vector<double> > >
Ez(NFILAS, vector< vector<double> >(NCOLUMNAS,
vector<double>(NFRAMES, 0.)));

in Borland C++ Builder 6. I supposse an instance of this vector is
created on the heap. Is that true? In such a case, should I destroy it
when I don't need it anymore to release resources?. I tried to do it
by mean the following sentence:

Ez.~vector< vector< vector<double> > >();

but I got the next exception

Project ModoTM.exe raised exception class EAccessViolation with
message 'Access violation at address 01194302 in module
'BORLNDMM.DLL'. Read of address 00001DA0'. Process stopped. Use Step
or Run to continue.

where is the mistake with this approach?

Thanks in advance ;-)

Gernot Frisch 01-13-2005 10:19 AM

Re: Someone knows how can I destroy a 3D vector?
 

"joseantonio" <joseantonio_79@ya.com> schrieb im Newsbeitrag
news:9f1c386f.0501130206.31f8f1b2@posting.google.c om...
> Hi all,
>
> I am novice in C++, (basically, novice using OOP). I am developing
> an
> application where I use a vector 3D defined as
>
> vector< vector< vector<double> > >
> Ez(NFILAS, vector< vector<double> >(NCOLUMNAS,
> vector<double>(NFRAMES, 0.)));
>
> in Borland C++ Builder 6. I supposse an instance of this vector is
> created on the heap. Is that true? In such a case, should I destroy
> it
> when I don't need it anymore to release resources?. I tried to do it
> by mean the following sentence:
>
> Ez.~vector< vector< vector<double> > >();


the object calls the destructor when it get's out of scope:

void foo()
{
vector<vector<vector<double> > > v3;
// can use it here
} // ~ will be called here

You never must call it. If you allocate something with 'new', the
corresponding 'delete' will call it before freeing memory.

HTH,
Gernot



Rolf Magnus 01-13-2005 03:49 PM

Re: Someone knows how can I destroy a 3D vector?
 
joseantonio wrote:

> Hi all,
>
> I am novice in C++, (basically, novice using OOP). I am developing an
> application where I use a vector 3D defined as
>
> vector< vector< vector<double> > >
> Ez(NFILAS, vector< vector<double> >(NCOLUMNAS,
> vector<double>(NFRAMES, 0.)));
>
> in Borland C++ Builder 6. I supposse an instance of this vector is
> created on the heap. Is that true? In such a case, should I destroy it
> when I don't need it anymore to release resources?. I tried to do it
> by mean the following sentence:
>
> Ez.~vector< vector< vector<double> > >();
>
> but I got the next exception
>
> Project ModoTM.exe raised exception class EAccessViolation with
> message 'Access violation at address 01194302 in module
> 'BORLNDMM.DLL'. Read of address 00001DA0'. Process stopped. Use Step
> or Run to continue.
>
> where is the mistake with this approach?


It doesn't matter whether it's vector or any other type. If you define a
local variable, it get automatically destroyed when it goes out of scope.
Eplicit destructor calls are only very rarely needed.


>
> Thanks in advance ;-)




All times are GMT. The time now is 11:11 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.