Mailinglist Archive: opensuse-programming (8 mails)

< Previous Next >
Re: [opensuse-programming] C++ inheritance issue
  • From: Jerry Feldman <gaf@xxxxxxx>
  • Date: Tue, 1 May 2007 19:47:15 -0400
  • Message-id: <20070501194715.60762201@xxxxxxxxxxx>
On Mon, 30 Apr 2007 21:47:19 +0100
John D Lamb <J.D.Lamb@xxxxxxxxxxxxxx> wrote:

> I think the this->i_key version is probably better if it's available,
> but, by chance, I found an example where it doesn't work in some code I
> wrote a couple of years ago:
> 
> class NextTrail : private
> Next<boost::graph_traits<cycleCentre::Graph>::vertices_size_type>{
>   ...
> };
> 
>                                                            
> bool
> NextTrail::operator()( VertexTrail* trail ){
>   ...
> while( Next<boost::graph_traits<Graph>::vertices_size_type>::operator()() ){
>     ...
>   }
>   ...
> }
> 
> I haven't worked out yet, why this doesn't work. Maybe its because of
> the private inheritance, but it does show that using this->operator()()
> isn't guaranteed to work.
I tested the use of the this, and it worked fine, and I changed the
code accordingly. But I have another related problem:
template <fooo>
class FuBar 
{
...
protected:
        FuBar(fooo *pf);
...
};

template <fooo>
class Bar: public Fubar<fooo>
        ...
        class BarFoo

}

Bar::Barfoo::Barfoo(fooo *pf)
        ...
        FuBar(fooo *pf);
        At this point, it does not allow me to use the FuBar
constructor. The solution was that I simply declared the FuBar(fooo
*pf); constructor as a public member, which worked. Both Bar and BarFoo
inherit FuBar, and should be able to call a protected constructor. My
exact syntax might be a bit off. 

-- 
Jerry Feldman <gaf@xxxxxxx>
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
< Previous Next >
List Navigation
This Thread
  • No further messages