|
-
Jun 14th, 2004, 03:26 AM
#1
Thread Starter
Addicted Member
erase in vector
<code>
vector<myrec> v
class myrec
{
int age;
char* name;
};
void sdelete()
{
if(v.size()>1)
system("CLS");
v.erase(v.begin());
}
void edelete()
{
if(v.size()>1)
system("CLS");
v.erase(v.end()-1);
}
</code>
When I use edelete() it works fine but when I use sdelete()
the last name element of the last element of the vector changes.
What did I do wrong here?
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
|