473,324 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Inheritance Problem

Hello Friends,

#include "iostream.h"

class A
{
public:

void fun( int i )
{
cout<<"A:Fun"<endl
}
};

class B
{
public:

void fun( int i, int j )
{
cout<<"B:Fun"<endl
}
};

class C: public A, public B
{
public:
void Print()
{
cout<<"C:Print"<<endl;
}
};

int main()
{
C obj;
obj.fun(0);
}

When I am trying to compile this code I am getting the error C2385: 'C::fun is ambiguousin VC6.

I am not able to understand why I am getting this error because the function fun is having the different number of argument in class A and class B. Even I change the type of the argument compiler is giving the same error.
Feb 26 '08 #1
2 1109
ashitpro
542 Expert 512MB
Hello Friends,

#include "iostream.h"

class A
{
public:

void fun( int i )
{
cout<<"A:Fun"<endl
}
};

class B
{
public:

void fun( int i, int j )
{
cout<<"B:Fun"<endl
}
};

class C: public A, public B
{
public:
void Print()
{
cout<<"C:Print"<<endl;
}
};

int main()
{
C obj;
obj.fun(0);
}

When I am trying to compile this code I am getting the error C2385: 'C::fun is ambiguousin VC6.

I am not able to understand why I am getting this error because the function fun is having the different number of argument in class A and class B. Even I change the type of the argument compiler is giving the same error.
Same problem has already come to this forum.
please check below thread
http://www.thescripts.com/forum/thread137040.html


The program is indeed in error. There are two kinds of ambiguity:
(1) name lookup ambiguity
(2) call ambiguity.

Since overload resolution takes place only after name lookup, you
can't expect overload resolution to pick A::fun, when you're already in
trouble with (1).
Feb 26 '08 #2
weaknessforcats
9,208 Expert Mod 8TB
Plus you are using iostream.h.

That is the pre-ANS C++ used before 1998.

You should be using iostream.
Feb 26 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
3
by: Morten Aune Lyrstad | last post by:
Hi again! I'm having problems with inheritance. I have a base interface class called IObject. Next I have two other interfaces classes, IControl and ICommandMaster, which derives from IObject. ...
14
by: Steve Jorgensen | last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling a particular case of implementation inheritance that would be easy and obvious in a fully OOP language, but is not at...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
8
by: Gaetan | last post by:
hi i have 2 classes A1 and A2 implementing a problem with 2 different ways i also have 2 other classes X1 and X2 implementing an other problem i need classes that provide A1+X1 methods,...
6
by: VR | last post by:
Hi, I read about Master Pages in ASP.Net 2.0 and after implementing some WinForms Visual Inheritance I tryed it with WebForms (let's say .aspx pages, my MasterPage does not have a form tag itself...
60
by: Shawnk | last post by:
Some Sr. colleges and I have had an on going discussion relative to when and if C# will ever support 'true' multiple inheritance. Relevant to this, I wanted to query the C# community (the...
5
by: colint | last post by:
Hi I'm fairly new to c++ and I have a question regarding inheritance. I'm trying to create a class based on 2 inherited classes, e.g. class A { ... } class B: public A
5
by: a | last post by:
Hi, I have an oop inheritance graph problem. What is the difference betweent the following 2 inheritance graph? How does the C++ solve the naming conflict problem for multiple inheritance...
3
by: Leo Seccia | last post by:
Hello everyone, I have a c# project with a sql server database. I have a number of lookup tables in my database which I successfully managed to import into my LINQ dataclasses. eg. Table:...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.