Home

Hey all,

I'm working on a project with a layout similar to this:

class A {
protected:
A *next;
int i;
public:
void m(A *a);
};

class B: public A {
public:
void m(B *b);
}

where both A and B are linked lists, but each one of its own type, and
m is a method that manipulates A's 'next' attribute, for instance:
A::m(A *a) {
a->next = next;
i++;
}

as the behavior would be exactly the same for B, I did:
B::m(B *b) {
A::m(b);
}

But that gives me errors on compiling whenever method B::m, tries to
access a protected member of class A (for instance incrementing i).
I've tried declaring a new variable i to class B, but that just causes
both A::i and B::i to exist, and A increments A::i, while whenever
someone reads from B, it reads B::i. Which is obviously wrong.

Does anybody know how I can fix this? Did anybody even understand what
I just asked? I know I kinda lost me. :P

Any help would be greatly appreciated,
Lucas

previous
next

RE: Setting stdout encoding
Re: TwistedMatrix missing OpenSSL?
Re: Visual C++ Express Edition or lcc-win32?
Re: C/C++ guidelines
Re: Memory layout question
praca w niemczech od zaraz
andrzej dąbrowski
odnawialne źródła energii
bjbeierde.com
poker