Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old September 25th, 2006, 08:45 PM
shuisheng
Guest
 
Posts: n/a
Default Type conversion ambiguity.

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

  #2  
Old September 25th, 2006, 09:35 PM
Victor Bazarov
Guest
 
Posts: n/a
Default Re: Type conversion ambiguity.

shuisheng wrote:
Quote:
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>'.
Quote:
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


  #3  
Old September 25th, 2006, 09:55 PM
shuisheng
Guest
 
Posts: n/a
Default Re: Type conversion ambiguity.


Victor Bazarov 写道:
Quote:
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.
Quote:
--
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?

  #4  
Old September 25th, 2006, 09:55 PM
Victor Bazarov
Guest
 
Posts: n/a
Default Re: Type conversion ambiguity.

shuisheng wrote:
Quote:
Victor Bazarov ??:
>
Quote:
>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.
Quote:
Quote:
>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


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,338 network members.