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

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

Sep 25 '06 #1
3 1840
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

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Terje Sletteb | last post by:
Hi. I'm new here, and sorry if this has been discussed before; I didn't find it searching the PHP groups. (I've also read recommendations to cross-post to the other PHP groups, but if that is...
5
by: Philip Pemberton | last post by:
Hi, I've just been trying to get some (pretty badly written) code working on a different compiler. Unfortunately, I've hit a problem. When the code below is compiled under Borland C++ it...
2
by: rasbury | last post by:
If I were to include in the definition of a string class the following operators: class String { public: // ... operator const char *() const; // conversion to C-style string char...
5
by: Fabio Fracassi | last post by:
Hi, I belive what i am trying to do is not possible, but I hope someone can change my mind. Here is some code i'd like to write: template <class type> class engine1 {}; template <class...
6
by: Arne Schmitz | last post by:
I guess this has been asked before, but I cannot find any answer to this problem. I have program like this: ---SNIP--- #include <cassert> #include <cstdlib> class C { public:
9
by: Erik Leunissen | last post by:
L.S. I've observed unexpected behaviour regarding the usage of the '#' flag in the conversion specification in the printf() family of functions. Did I detect a bug, or is there something wrong...
7
by: Madhu Gopinathan | last post by:
Hi, I hope this is the right forum for this question. I am extending ICollection to create a Collection Type (say MyCollection) wherein I can control the types of objects being added to the...
0
by: Brian Henry | last post by:
I am working with the control available at http://www.windowsforms.net/default.aspx?tabindex=6&tabid=47&ItemID=10&mid=142 I have noticed that on lines 599 - 603 of the file HtmlEditor.cs there...
6
by: Rahul | last post by:
Hi Everyone, I have the following code, class B; class A { public : operator B();
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shllpp 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.