473,796 Members | 2,550 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error C2385 on (ctor)

PLS
I'm converting some C++ code to VC++ 2005 in native (non-managed) mode.
This code doesn't use ATL, but codes the COM mechanisms directly.

It has a class which is the equivalent of ATL's IDispatchImpl:

template<class T>
class CDispatch : virtual public IDispatch, virtual public CUnknown,
private CDispatchBase
{
...

CDispatch::CDis patch(IUnknown *pOuterUnknown)
: CUnknown(pOuter Unknown),
m_pITypeInfo(0)
{}

...
};

The constructor produces this error:

c:\project\pciw \cdisp.h(253) : error C2385: ambiguous access of '{ctor}'
could be the '{ctor}' in base 'IDispatch'
or could be the '{ctor}' in base 'CUnknown'
or could be the '{ctor}' in base 'CDispatchBase'
c:\project\pciw \cdisp.h(285) : see reference to class template
instantiation 'CDispatch<T>' being compiled
I understand about name collisions and disambiguation for methods in
multiple inheritance. How do you disambiguate a constructor?

Seriously, how do I fix this?

Thanks,
++PLS
Jan 11 '07 #1
5 2878
1. Is it correct that CDispatchBase inherits CUnknown (non virtually)? Is it
your intention?
2. Can you define CDispatch constructor this way:

CDispatch::CDis patch(IUnknown *pOuterUnknown)
: CDispatch::CUnk nown(pOuterUnkn own),
m_pITypeInfo(0)
{}

?

I'm converting some C++ code to VC++ 2005 in native (non-managed) mode.
This code doesn't use ATL, but codes the COM mechanisms directly.

It has a class which is the equivalent of ATL's IDispatchImpl:

template<class T>
class CDispatch : virtual public IDispatch, virtual public CUnknown,
private CDispatchBase
{
...

CDispatch::CDis patch(IUnknown *pOuterUnknown)
: CUnknown(pOuter Unknown),
m_pITypeInfo(0)
{}

...
};

The constructor produces this error:

c:\project\pciw \cdisp.h(253) : error C2385: ambiguous access of '{ctor}'
could be the '{ctor}' in base 'IDispatch'
or could be the '{ctor}' in base 'CUnknown'
or could be the '{ctor}' in base 'CDispatchBase'
c:\project\pciw \cdisp.h(285) : see reference to class template
instantiation 'CDispatch<T>' being compiled
I understand about name collisions and disambiguation for methods in
multiple inheritance. How do you disambiguate a constructor?

Thanks.
--
Vladimir Nesterovsky
Jan 11 '07 #2
PLS
Changing the constructor as you suggest gives exactly the same error.
And I get that error without the virtuals in the class declaration.

CDispatchBase has no base classes.

IDispatch has IUnknown as a base class.

CUnknown has IUnknown as a base class.

And removing CUnknown and "virtual" from the CDisp base classes gives a
very similar error message:
c:\project\pciw \cdisp.h(253) : error C2385: ambiguous access of '{ctor}'
could be the '{ctor}' in base 'IDispatch'
or could be the '{ctor}' in base 'CDispatchBase'
c:\project\pciw \cdisp.h(284) : see reference to class template
instantiation 'CDispatch<T>' being compiled

I'm stumped. It looks like C++ 2005 just can't handle multiple
inheritance. Any base class is going to have a constructor.

++PLS

In article <eL************ **@TK2MSFTNGP06 .phx.gbl>,
vl******@nester ovsky-bros.com says...
1. Is it correct that CDispatchBase inherits CUnknown (non virtually)? Is it
your intention?
2. Can you define CDispatch constructor this way:

CDispatch::CDis patch(IUnknown *pOuterUnknown)
: CDispatch::CUnk nown(pOuterUnkn own),
m_pITypeInfo(0)
{}

?

I'm converting some C++ code to VC++ 2005 in native (non-managed) mode.
This code doesn't use ATL, but codes the COM mechanisms directly.

It has a class which is the equivalent of ATL's IDispatchImpl:

template<class T>
class CDispatch : virtual public IDispatch, virtual public CUnknown,
private CDispatchBase
{
...

CDispatch::CDis patch(IUnknown *pOuterUnknown)
: CUnknown(pOuter Unknown),
m_pITypeInfo(0)
{}

...
};

The constructor produces this error:

c:\project\pciw \cdisp.h(253) : error C2385: ambiguous access of '{ctor}'
could be the '{ctor}' in base 'IDispatch'
or could be the '{ctor}' in base 'CUnknown'
or could be the '{ctor}' in base 'CDispatchBase'
c:\project\pciw \cdisp.h(285) : see reference to class template
instantiation 'CDispatch<T>' being compiled
I understand about name collisions and disambiguation for methods in
multiple inheritance. How do you disambiguate a constructor?


Thanks.
--
Vladimir Nesterovsky

Jan 11 '07 #3

"PLS" <no****@nowhere .comwrote in message
news:MP******** *************** *@msnews.micros oft.com...
Changing the constructor as you suggest gives exactly the same error.
And I get that error without the virtuals in the class declaration.

CDispatchBase has no base classes.

IDispatch has IUnknown as a base class.

CUnknown has IUnknown as a base class.

And removing CUnknown and "virtual" from the CDisp base classes gives a
very similar error message:
c:\project\pciw \cdisp.h(253) : error C2385: ambiguous access of '{ctor}'
could be the '{ctor}' in base 'IDispatch'
or could be the '{ctor}' in base 'CDispatchBase'
c:\project\pciw \cdisp.h(284) : see reference to class template
instantiation 'CDispatch<T>' being compiled

I'm stumped. It looks like C++ 2005 just can't handle multiple
inheritance. Any base class is going to have a constructor.
Have you tried the Comeau online compiler? If it accepts the code then
Visual C++ definitely has a bug. If not, it may yield a much clearer error
message.
++PLS

In article <eL************ **@TK2MSFTNGP06 .phx.gbl>,
vl******@nester ovsky-bros.com says...
>1. Is it correct that CDispatchBase inherits CUnknown (non virtually)? Is
it
your intention?
2. Can you define CDispatch constructor this way:

CDispatch::CDi spatch(IUnknown *pOuterUnknown)
: CDispatch::CUnk nown(pOuterUnkn own),
m_pITypeInfo(0)
{}

?

I'm converting some C++ code to VC++ 2005 in native (non-managed) mode.
This code doesn't use ATL, but codes the COM mechanisms directly.

It has a class which is the equivalent of ATL's IDispatchImpl:

template<class T>
class CDispatch : virtual public IDispatch, virtual public CUnknown,
private CDispatchBase
{
...

CDispatch::CDis patch(IUnknown *pOuterUnknown)
: CUnknown(pOuter Unknown),
m_pITypeInfo(0)
{}

...
};

The constructor produces this error:

c:\project\pciw \cdisp.h(253) : error C2385: ambiguous access of
'{ctor}'
could be the '{ctor}' in base 'IDispatch'
or could be the '{ctor}' in base 'CUnknown'
or could be the '{ctor}' in base 'CDispatchBase'
c:\project\pciw \cdisp.h(285) : see reference to class template
instantiation 'CDispatch<T>' being compiled
I understand about name collisions and disambiguation for methods in
multiple inheritance. How do you disambiguate a constructor?


Thanks.
--
Vladimir Nesterovsky


Jan 11 '07 #4
PLS
In article <ey************ **@TK2MSFTNGP03 .phx.gbl>, rb*@nospam.nospam
says...
Comeau online compiler
Actually, that helped. Thank you.

Here's what the problem is:

template<class T>
class CDispatch : virtual public IDispatch, virtual public CUnknown,
private CDispatchBase
{
...

CDispatch::CDis patch(IUnknown *pOuterUnknown)
: CUnknown::CUnkn own(pOuterUnkno wn),
m_pITypeInfo(0)
{}
CDispatch::~CDi spatch()
{
if (m_pITypeInfo != NULL)
{
m_pITypeInfo->Release();
}
}

...
};

The Comeau compiler tells me:
"ComeauTest .c", line 379: error: qualified name is not allowed in member
declaration
CDispatch::CDis patch(IUnknown *pOuterUnknown)

Remove the "CDispatch: :" from these two methods and everything works.

I guess this is a restriction in the new C++ standard. Can anyone
confirm this?

I think this is a compiler bug, because of the horribly off target
message. Can anyone tell me how to file a bug report?

Thanks,
++PLS
Jan 12 '07 #5

"PLS" <no****@nowhere .comwrote in message
news:MP******** *************** *@msnews.micros oft.com...
In article <ey************ **@TK2MSFTNGP03 .phx.gbl>, rb*@nospam.nospam
says...
>Comeau online compiler
Actually, that helped. Thank you.

Here's what the problem is:

template<class T>
class CDispatch : virtual public IDispatch, virtual public CUnknown,
private CDispatchBase
{
...

CDispatch::CDis patch(IUnknown *pOuterUnknown)
: CUnknown::CUnkn own(pOuterUnkno wn),
m_pITypeInfo(0)
{}
CDispatch::~CDi spatch()
{
if (m_pITypeInfo != NULL)
{
m_pITypeInfo->Release();
}
}

...
};

The Comeau compiler tells me:
"ComeauTest .c", line 379: error: qualified name is not allowed in member
declaration
CDispatch::CDis patch(IUnknown *pOuterUnknown)
Oh, your functions are defined inside the class declaration block,
definitely you shouldn't double up the class name.
>
Remove the "CDispatch: :" from these two methods and everything works.

I guess this is a restriction in the new C++ standard. Can anyone
confirm this?
I think you were instructing the compiler to look for a nested class.
>
I think this is a compiler bug, because of the horribly off target
message. Can anyone tell me how to file a bug report?
https://connect.microsoft.com/feedba...spx?SiteID=210
>
Thanks,
++PLS

Jan 12 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
17499
by: Glenn A. Harlan | last post by:
Why am I receiving the below error when calling - Path.GetTempFileName() The directory name is invalid. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IO.IOException: The directory name is invalid.
1
2952
by: Prakru | last post by:
Hello guys, I get compilation error for the following code in MS VC++ 6 compiler: I thought that if the Eject is called with no args, then the Player::Eject () should be called. But it is not working.
3
3350
by: murphy | last post by:
Hi, I've been seeing two symptoms with my asp.net site that have started recently after a long period of smooth running. As others on our team make changes to referenced dll's I find that I get the following errors from time to time. Apparently the following procedure alleviates the problems:
5
1839
by: Patrick | last post by:
I understand it is built in behaviour that if an ASP.NET's web.config is set to: <customErrors mode="RemoteOnly" /> then I only get a detailed error message on screen when the ASP.NET application is executed on the IIS server itself. However, I note that with the following
0
2267
by: Joergen Bech | last post by:
Fairly new to ASP.NET 1.1. Getting the error below when running application on a web server outside of my control, but only the first time I run it: 1. After a long period of inactivity (or updating the code-behind dll) accessing any aspx page in the application causes the application to run for the first time. Some of the initialization involves reading and writing some text and xml files using simple streamreader and streamwriter...
2
1930
by: Brecht Yperman | last post by:
Hi, when calling the XmlSerializer constructor, I get the following error: Top Level Exception Type: System.IO.IOException Message: Unknown Error (-1). Source: mscorlib Stack Trace: at System.IO.__Error.WinIOError(Int32 errorCode, String str)
0
2661
by: Marty Cruise | last post by:
I successfully deploy my application to 20 domain users. Only one new user is giving me a problem, although he can access all domain resources. When he clicks the installation link on the publish page, Framework 2.0 installs successfully, but then the application installation fails during the "Verifying Application Requirements" process. Can anyone help me figure out how to solve this? Error is as follows. PLATFORM VERSION INFO...
2
1563
by: subramanian | last post by:
Consider the following program: #include <iostream> #include <string> class Member { int x; int y; public: Member(int argx, int argy);
0
5254
by: Tifer | last post by:
Hello, I am building my first .Net Application. The first couple of Publish and Installs I did went fine. But after a couple of builds, I get a modal dialogue box error every time upon trying to install using the setup.exe. Title is "Cannot Start Application" and it says: ==================== Cannot download the application. The application is missing required files. Contact application vendor for assistance.
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10237
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10187
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10018
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7553
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6795
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4120
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.