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

Type conversion ambiguity.

P: n/a
Dear All,

Such as I have a template class Base<intwhich can automaticaaly
convert to base<douoble>.

Base<int <= Base<double>

And also I have a derived class Derived<intwhich can automatically
convert to Derived<double>.

Derived<int<= Derived<double>

And I have a function

void fun(Base<int>)

If I call

Derived <doublea;
fun(a);

It is ambiguous in the type conversion. Is there any good way I can
avoid it?

Thanks,

Tian

Sep 25 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
shuisheng wrote:
Such as I have a template class Base<intwhich can automaticaaly
convert to base<douoble>.

Base<int <= Base<double>

And also I have a derived class Derived<intwhich can automatically
convert to Derived<double>.

Derived<int<= Derived<double>
You probably forgot to mention that 'Derived<X>' is actually derived
from 'Base<X>'.
And I have a function

void fun(Base<int>)

If I call

Derived <doublea;
fun(a);

It is ambiguous in the type conversion. Is there any good way I can
avoid it?
What do you mean by "to avoid"? Which one do you actually need? Or
do you want an error message instead?

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

P: n/a

Victor Bazarov 写道:
What do you mean by "to avoid"? Which one do you actually need? Or
do you want an error message instead?
Got your message, Thanks.
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
I am wondering what is capital 'A's?

Sep 25 '06 #3

P: n/a
shuisheng wrote:
Victor Bazarov ??:
>What do you mean by "to avoid"? Which one do you actually need? Or
do you want an error message instead?

Got your message, Thanks.
You're welcome. Glad I could help.
>Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask

I am wondering what is capital 'A's?
Those are letters 'A' (compared to letters 'a', which are called "small",
if memory serves me).

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

This discussion thread is closed

Replies have been disabled for this discussion.