[Insight-developers] inheritance

debbie larson debbielarson_9 at hotmail.com
Mon May 28 21:44:37 EDT 2007


Hi Peter and Luis,

Thanks. Your help did solve the problems.

deb


>From: Luis Ibanez <luis.ibanez at kitware.com>
>To: Peter Cech <pcech at vision.ee.ethz.ch>,  debbie larson 
><debbielarson_9 at hotmail.com>
>CC: insight-developers at itk.org
>Subject: Re: [Insight-developers] inheritance
>Date: Sun, 27 May 2007 10:32:48 -0400
>
>
>Hi Debbie,
>
>Please not that if your derived class is a templated class,
>then you still need to add the "typename" keyword to your
>declaration.
>
>
>Like:
>
>    typedef  typename Superclass::IndexType    IndexType
>
>not just:
>
>    typedef           Superclass::IndexType    IndexType
>
>
>
>
>If you are using a recent CVS checkout of ITK,
>then you can take advantage of the macro:
>
>
>         itkSuperclassTraits( IndexType );
>
>
>for generating the correct typedef.
>
>
>
>
>Regards,
>
>
>    Luis
>
>
>------------------
>Peter Cech wrote:
>>On Sat, May 26, 2007 at 02:24:04 +0000, debbie larson wrote:
>>
>>>Hi,
>>>
>>>This is a basic question on inheritance but I am stuck. I wrote a class 
>>>that inherits from FloodFilledFunctionConditionalConstIterator. Thus in 
>>>the .h file I wrote
>>>
>>>template<class TImage, class TFunction>
>>>class ITK_EXPORT FloodFilledFunctionConditionalConstIterator2:
>>>   public FloodFilledFunctionConditionalConstIterator<TImage,TFunction>
>>>
>>>Now the parent class has several typedefs that I would like to use in the 
>>>child class. For example it has
>>>
>>>  typedef typename TImage::IndexType  IndexType;
>>>
>>>How do I use IndexType in the child class?
>>>
>>>I tried
>>>
>>>const IndexType & topIndex = m_IndexStack.front();
>>>
>>>then I tried
>>>
>>>const Superclass::IndexType & topIndex = m_IndexStack.front();
>>
>>
>>As for the type the above should work. You can do
>>
>>   typedef Superclass::IndexType    IndexType
>>
>>for convenience. Another thing that can go wrong is access to
>>Superclass' member variables. One has to access them via this->
>>
>>   const Superclass::IndexType & topIndex = this->m_IndexStack.front();
>>
>>This is requirement of C++ standard - AFAIK only for inheriting
>>templated classes, but does not hurt if you use it everywhere.
>>
>>If there are still problems, post the relevant code and compiler error.
>>
>>Regards,
>>Peter
>>
>>_______________________________________________
>>Insight-developers mailing list
>>Insight-developers at itk.org
>>http://www.itk.org/mailman/listinfo/insight-developers
>>

_________________________________________________________________
PC Magazine’s 2007 editors’ choice for best Web mail—award-winning Windows 
Live Hotmail. 
http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HM_mini_pcmag_0507



More information about the Insight-developers mailing list