<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Abhishek wrote:
<blockquote cite="mid200503101245666.SM01612@AGworkstation" type="cite">
<meta http-equiv="Content-Type" content="text/html; ">
<meta name="Generator" content="Microsoft Word 11 (filtered medium)">
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:Arial;
        color:windowtext;}
@page Section1
        {size:612.1pt 792.1pt;
        margin:.5in .2in .6in .5in;}
div.Section1
        {page:Section1;}
-->
</style>
<div class="Section1">
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">When I use: <o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">std::auto_ptr<vtkTIFFReader>
m_pImgReader;<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">as a member variable in
my class I get the following
compiler (MSVC) error:<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">…\memory(484): error C2248:
'vtkTIFFReader::vtkTIFFReader' :
cannot access protected member declared in class 'vtkTIFFReader'.<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">Can someone throw light as to why this is
happening? Thanks,</span></font></p>
</div>
</blockquote>
VTK objects already have "auto_ptr style semantics." For raw pointer
usage, the expected usage is to call <b>vtkTIFFReader::New</b> and
then call <b>Delete</b> on the returned pointer when you're done.
(Note the captial letters in <b>New</b> and <b>Delete</b>.) To keep
folks from bypassing the VTK object ref counting mechanism, the default
constructors and the destructors of VTK objects are protected. So using
std::auto_ptr would be a mistake and the compiler has prevented you
from making it in this case...<br>
<br>
See also the class "<b>vtkSmartPointer</b>" found in
VTK/Common/vtkSmartPointer.h... It's VTK's equivalent to std::auto_ptr,
so you can usually just call <b>New</b> and forget about it.<br>
<br>
HTH,<br>
Dave<br>
<br>
</body>
</html>