www.digitalmars.com         C & C++   DMDScript  

c++ - how to solve "need explicit cast to convert"???

reply konst <kdiguine yandex.ru> writes:
hi, all!

I'm trying to compile yassl using dmc for dos real mode. everything
seems ok but i've got an error: "need explicit cast to convert" in the
following code ():

...
const Integer& Multiply(const Integer &a, const Integer &b) const
        {
            return result1 = a * b % modulus; // error is here!
        }
...
protected:
    Integer modulus;
    mutable Integer result, result1;
...

Integer is a class with lots of methods.
should I remove this "const" from all methods like "Multiply" or is
there another way?

thanx!
Oct 28 2008
parent Heinz Saathoff <newshsaat arcor.de> writes:
Hello,

konst wrote ...
 I'm trying to compile yassl using dmc for dos real mode. everything
 seems ok but i've got an error: "need explicit cast to convert" in the
 following code ():
 
 ...
 const Integer& Multiply(const Integer &a, const Integer &b) const
         {
             return result1 = a * b % modulus; // error is here!
         }
 ...
 protected:
     Integer modulus;
     mutable Integer result, result1;
 ...
 
 Integer is a class with lots of methods.
 should I remove this "const" from all methods like "Multiply" or is
 there another way?
Seems to be a bug in DMC. My PC-Lint and the borland C++ compile this example, but DMC does not: class Integer { public: Integer(); Integer & operator= (const Integer &rhs); friend Integer operator* (const Integer &a, const Integer &b); friend Integer operator% (const Integer &a, const Integer &b); }; class MyInteger { public: const Integer& Multiply(const Integer &a, const Integer &b) const { return result1 = a * b % modulus; // error is here! } protected: Integer modulus; mutable Integer result, result1; }; int foo() { MyInteger a, b, c; return 0; } Maybe there is a problem with the handling of mutable here? - Heinz
Oct 29 2008