ssercpp12 / Homework

Homework result for 12 sser cpp
1 stars 8 forks source link

the function of Remove #18

Open sswei opened 11 years ago

sswei commented 11 years ago

// Removes the Value with the specified index from this list. // If |out_value| is non-NULL, the removed Value AND ITS OWNERSHIP will be // passed out via |out_value|. If |out_value| is NULL, the removed value will // be deleted. This method returns true if |index| is valid; otherwise // it will return false and the ListValue object will be unchanged. virtual bool Remove(size_t index, Value\ out_value);

师兄,这个函数不就是remove掉一个元素就好了吗?out_value不为空会怎样?没看懂。。

ssercpp12 commented 11 years ago

// If |out_value| is non-NULL, the removed Value AND ITS OWNERSHIP will be // passed out via |out_value|.

which means that the *out_value will point to the removed Value.(You just remove the pointer from the list_, do not need to delete the memory.) And who use this function should manage the memory.

sswei commented 11 years ago

I get it!THX!