By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,413 Members | 1,023 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,413 IT Pros & Developers. It's quick & easy.

no unique overrider errors...

P: n/a
Hey,

I'm a little new to c++ programming. I've created a class that inherits
from two other classes

class C: virtual public A, public B
{
...
}

now, the thing is, i have no clue what the classes A & B have in them,
i have no access to the source files. There're obviously some virtual
functions there; because i get
"no unique overrider.." errors for a multitude of functions in classes
A and B. I don't *want* to use the functions that have no unique
overriders; but i also can't go to single inheritance because i need
methods from both the classes.

any clues/explanations as to what is happening? I can't understand
this, and it's driving me crazy.

thanks.

Jul 10 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
pa******@gmail.com wrote:
Hey,

I'm a little new to c++ programming. I've created a class that inherits
from two other classes

class C: virtual public A, public B
{
...
}

now, the thing is, i have no clue what the classes A & B have in them,
Yes you do, you must have their declarations in order to inherit from them.
i have no access to the source files. There're obviously some virtual
functions there; because i get
"no unique overrider.." errors for a multitude of functions in classes
A and B. I don't *want* to use the functions that have no unique
overriders; but i also can't go to single inheritance because i need
methods from both the classes.
I assume that error is telling you the classes have pure virtual methods
and you haven't implemented them in your class. You must.

--
Ian Collins.
Jul 10 '06 #2

P: n/a
Ian Collins wrote:
pa******@gmail.com wrote:
>Hey,

I'm a little new to c++ programming. I've created a class that
inherits from two other classes

class C: virtual public A, public B
{
...
}

now, the thing is, i have no clue what the classes A & B have in
them,

Yes you do, you must have their declarations in order to inherit from
them.
Ahem... "Definitions". Declarations are usually not enough.
[...]
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jul 10 '06 #3

P: n/a

Victor Bazarov wrote:
Ian Collins wrote:
pa******@gmail.com wrote:
Hey,

I'm a little new to c++ programming. I've created a class that
inherits from two other classes

class C: virtual public A, public B
{
...
}

now, the thing is, i have no clue what the classes A & B have in
them,
Yes you do, you must have their declarations in order to inherit from
them.

Ahem... "Definitions". Declarations are usually not enough.
[...]

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask

So yeah, I do have the declarations, but not the definitions. And
here's the annoying bit. The functions are implemented, because when i
inherit from only one class, the errors disappear; this leads me to
believe that both my A & B classes in turn inherit from another base
class. And they both have their own, different implementations of the
methods. Which is why the "unique bit in the error message. not to
bandy terms around or anything, but is this like the diamond
inheritance problem or something?

My last option would be to single inherit from one class, and just
rewrite code that i need from the other.

Jul 10 '06 #4

P: n/a
pa******@gmail.com wrote:
Victor Bazarov wrote:
>>Ian Collins wrote:
>>>pa******@gmail.com wrote:

Hey,

I'm a little new to c++ programming. I've created a class that
inherits from two other classes

class C: virtual public A, public B
{
...
}

now, the thing is, i have no clue what the classes A & B have in
them,

Yes you do, you must have their declarations in order to inherit from
them.

Ahem... "Definitions". Declarations are usually not enough.

So yeah, I do have the declarations, but not the definitions. And
here's the annoying bit. The functions are implemented, because when i
inherit from only one class, the errors disappear; this leads me to
believe that both my A & B classes in turn inherit from another base
class. And they both have their own, different implementations of the
methods. Which is why the "unique bit in the error message. not to
bandy terms around or anything, but is this like the diamond
inheritance problem or something?
Have you called A's constructor? I didn't spot the virtual inheritance
before.

Please trim signatures in your replies.

--
Ian Collins.
Jul 10 '06 #5

P: n/a
pa******@gmail.com schrieb:
Hey,

I'm a little new to c++ programming. I've created a class that inherits
from two other classes

class C: virtual public A, public B
{
...
}

now, the thing is, i have no clue what the classes A & B have in them,
i have no access to the source files. There're obviously some virtual
functions there; because i get
"no unique overrider.." errors for a multitude of functions in classes
A and B.
Look for virtual functions in A, B or their bases, that have the same
name in the A family as in the B family. Then override the function in
class C (maybe a using; would be enough).

Pseudo code:

struct A
{
virtual void foo();
};

struct B
{
virtual void foo();
};

struct C : virtual public A, virtual public B
{
virtual void foo() { A::foo(); }
// or: using A::foo;
};

The compiler doesn't know what function it should put into the vtbl, so
it asks you to specify one.

--
Thomas
Jul 10 '06 #6

P: n/a
pa******@gmail.com wrote:
Hey,

I'm a little new to c++ programming. I've created a class that inherits
from two other classes

class C: virtual public A, public B
{
...
}

now, the thing is, i have no clue what the classes A & B have in them,
Then you should not be using them. You could figure out what they have
in them, though, by reading their documentation, or, if there isn't any,
looking at the headers that define them. You cannot write sensible code
without that information.
Jul 11 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.