Mailinglist Archive: opensuse-programming (25 mails)
| < Previous | Next > |
Re: [opensuse-programming] C++ inheritance issue
- From: Jerry Feldman <gaf@xxxxxxx>
- Date: Mon, 30 Apr 2007 09:07:08 -0400
- Message-id: <20070430090708.0a1e0221@xxxxxxxxxxx>
On Sat, 28 Apr 2007 18:10:59 +0100
John D Lamb <J.D.Lamb@xxxxxxxxxxxxxx> wrote:
> On Sat, 2007-04-28 at 11:00 -0400, Jerry Feldman wrote:
> > No. this->i_key is equivalent to i_key in a member function.
> > The issue is with the dual template arguments. i_key is defined in the
> > base class as:
> > ThisType const & i_key;
> >
> > But the inheriting class does not include the ThisType template
> > parameter. The correct solution, as I found out yesterday afternoon is
> > to refer to i_key as fully qualified:
> > FuBar<ItemType, type_t>::i_key;
>
> That should also work because it makes i_key nondependent and I'm not
> surprised you spotted that one so quickly.
>
> Was there something about the context of i_key that made this->i_key not
> work? I don't think I've encountered a context in which it would fail,
> but it wouldn't surprise me if there are some.
>
> My instinct says we've found alternative solutions to the same problem.
> Mine avoids some problems with virtual function calls, but I suspect
> there is going to be some occasion when it won't work.
Hi John,
I just changed the code from FuBar<ItemType, type_t>::i_key; to
this->i_key, and that also resolved the issue. I appreciate your
response on this.
--
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
John D Lamb <J.D.Lamb@xxxxxxxxxxxxxx> wrote:
> On Sat, 2007-04-28 at 11:00 -0400, Jerry Feldman wrote:
> > No. this->i_key is equivalent to i_key in a member function.
> > The issue is with the dual template arguments. i_key is defined in the
> > base class as:
> > ThisType const & i_key;
> >
> > But the inheriting class does not include the ThisType template
> > parameter. The correct solution, as I found out yesterday afternoon is
> > to refer to i_key as fully qualified:
> > FuBar<ItemType, type_t>::i_key;
>
> That should also work because it makes i_key nondependent and I'm not
> surprised you spotted that one so quickly.
>
> Was there something about the context of i_key that made this->i_key not
> work? I don't think I've encountered a context in which it would fail,
> but it wouldn't surprise me if there are some.
>
> My instinct says we've found alternative solutions to the same problem.
> Mine avoids some problems with virtual function calls, but I suspect
> there is going to be some occasion when it won't work.
Hi John,
I just changed the code from FuBar<ItemType, type_t>::i_key; to
this->i_key, and that also resolved the issue. I appreciate your
response on this.
--
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 > |