473,396 Members | 1,707 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,396 software developers and data experts.

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::CDispatch(IUnknown *pOuterUnknown)
: CUnknown(pOuterUnknown),
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 2832
1. Is it correct that CDispatchBase inherits CUnknown (non virtually)? Is it
your intention?
2. Can you define CDispatch constructor this way:

CDispatch::CDispatch(IUnknown *pOuterUnknown)
: CDispatch::CUnknown(pOuterUnknown),
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::CDispatch(IUnknown *pOuterUnknown)
: CUnknown(pOuterUnknown),
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******@nesterovsky-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::CDispatch(IUnknown *pOuterUnknown)
: CDispatch::CUnknown(pOuterUnknown),
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::CDispatch(IUnknown *pOuterUnknown)
: CUnknown(pOuterUnknown),
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.microsoft.c om...
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******@nesterovsky-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::CDispatch(IUnknown *pOuterUnknown)
: CDispatch::CUnknown(pOuterUnknown),
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::CDispatch(IUnknown *pOuterUnknown)
: CUnknown(pOuterUnknown),
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::CDispatch(IUnknown *pOuterUnknown)
: CUnknown::CUnknown(pOuterUnknown),
m_pITypeInfo(0)
{}
CDispatch::~CDispatch()
{
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::CDispatch(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.microsoft.c om...
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::CDispatch(IUnknown *pOuterUnknown)
: CUnknown::CUnknown(pOuterUnknown),
m_pITypeInfo(0)
{}
CDispatch::~CDispatch()
{
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::CDispatch(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
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...
1
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...
3
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...
5
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...
0
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...
2
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...
0
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...
2
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
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...

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.