Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Someone knows how can I destroy a 3D vector?

Reply
Thread Tools

Someone knows how can I destroy a 3D vector?

 
 
joseantonio
Guest
Posts: n/a
 
      01-13-2005
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
 
Reply With Quote
 
 
 
 
Gernot Frisch
Guest
Posts: n/a
 
      01-13-2005

"joseantonio" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed) 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


 
Reply With Quote
 
 
 
 
Rolf Magnus
Guest
Posts: n/a
 
      01-13-2005
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
When to destroy, when not to destroy Ook C++ 2 10-11-2005 02:11 AM
Surely Someone Knows? george Computer Security 12 02-18-2004 07:52 PM
Someone knows something about "LMMC" as it should be a format of XML ?? sandhase XML 1 11-10-2003 02:06 PM
Maybe someone knows about Nodals Dane Brickman Digital Photography 2 08-15-2003 09:38 PM



Advertisments