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