You have to make a copy instead, e.g.: path.add_element()->CopyFrom(ele); delete ele;
On Thu, Aug 6, 2009 at 3:21 AM, 李海波 <[email protected]> wrote: > Path path; > Element* ele = new Element(); > if( condition ){ > delete ele; > }else{ > //add ele to path,how can I do? > } If your code really looks like this, you should probably change it to: Path path; Element* ele = path.add_element(); if (condition) { path.mutable_element()->RemoveLast(); } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~----------~----~----~----~------~----~------~--~---
