Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does this cause a mem leak?

Status
Not open for further replies.

maluk

Programmer
Oct 12, 2002
79
SG
Assuming I have a vector and an iterator for it. Assuming also that the vector contains elements. Also assume a function fxn() exists.

Code:
...
struct A;
void fxn(A& theA);
...
vector<A> vectorA;
vector<A>::iterator iterA;
...
...
for(iterA = vectorA.begin(); iterA != vectorA.end(); ++iterA)
{
    fxn(*iterA);
}

Does the call to fxn() assuming that fxn does something with the parameter it gets, say write to a file or to add it to another vector cause a memory leak?

Rome did not create a great empire by having meetings, they did it by
killing all those who opposed them.

- janvier -
 
Not unless fxn uses the keywork new and doesn't call delete.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top