|
-
March 12th, 2009, 10:24 AM
#3
Re: destroying STL vectors explicitly?
 Originally Posted by MrViggy
You can do it that way. Access the members with the '->' operator, or:
Code:
int someVal = (*inTetr)[3];
Another options is to enclose this section in it's own block:
Code:
int main()
{
int someVal = 0;
{
std::vector<int> someVec;
...
}
// someVec is now out of scope, and destroyed
}
Viggy
Ah, okay. That's a head-slapper. I was using the reference operator, but I wasn't placing the parentheses. Though it makes perfect sense why that would be necessary.
I knew about the swap trick, but that just felt...dirty somehow. I wanted to completely delete the vector.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|