Type conversion ambiguity.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shuisheng

    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<intwhic h 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

  • Victor Bazarov

    #2
    Re: Type conversion ambiguity.

    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<intwhic h 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


    Comment

    • shuisheng

      #3
      Re: Type conversion ambiguity.


      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?

      Comment

      • Victor Bazarov

        #4
        Re: Type conversion ambiguity.

        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


        Comment

        Working...