<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
Hi, vtkers.<BR>
&nbsp;<BR>
I have a question regarding pointer new and delete. Here is the code<BR>
&nbsp;<BR>
main(){<BR>
....<BR>
&nbsp;vtkPoints *LSPoints = vtkPoints::New();<BR>&nbsp;fun ( LSV, &amp;LSPoints );<BR>
&nbsp;std::cout&lt;&lt; LSPoints-&gt;GetNumberOfPoints()&lt;&lt;std::endl;.......................................(1)<BR>
....<BR>
&nbsp;LSPoints-&gt;Delete();<BR>
}<BR>
&nbsp;<BR>
fun( vtkImage LSV,&nbsp;vtkPoints **pLSPoints )<BR>
{<BR>
&nbsp;vtkContourFilter *LSFilter = vtkContourFilter::New();<BR>&nbsp;LSFilter-&gt;SetInput( vtkLSV );<BR>&nbsp;LSFilter-&gt;SetValue( 0, 0 );&nbsp;<BR>&nbsp;LSFilter-&gt;Update();<BR>
&nbsp;*pLSPoints = LSFilter-&gt;GetOutput()-&gt;GetPoints();&nbsp;<BR>
&nbsp;std::cout&lt;&lt; (*pLSPoints)-&gt;GetNumberOfPoints()&lt;&lt;std::endl;.................................(2)<BR>&nbsp;LSFilter-&gt;Delete();<BR>
}<BR>
&nbsp;<BR>
The output at position 2 is correct where as the output at position 1 is destroyed. <BR>
If I comment "LSfilter-&gt;Delete()", then the output at both locations are correct.&nbsp; But I think I need to release the memory of LSFilter here.<BR>
&nbsp;<BR>
pls point out where I am wrong.<BR>
&nbsp;<BR>
Thanks for any input.<BR>
Siqi<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;<BR>
<RTE_TEXT></RTE_TEXT><BR><br /><hr />更多热辣资讯尽在新版MSN首页! <a href='http://cn.msn.com/' target='_new'>立刻访问!</a></body>
</html>