how to fix this error error C2582: 'operator =' function is unavailable in
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
#include<iostream>
#include"LongDouble.h"
using namespace std;
LongDouble::LongDouble()
{
sign = 0;
exponent = 2;
for (int i = 0; i < 7;i++)
mantissa [i]=i;
}
LongDouble LongDouble::operator+( LongDouble& olong)
{
LongDouble temp;
if (this->sign == 0 && olong.sign == 0)
{
temp.exponent = this->exponent + olong.exponent;
for (int i = 0; i < 7; i++)
temp.mantissa[i] = this->mantissa[i] + olong.mantissa[i];
if (temp.mantissa[1] > 9)
{
temp.exponent += 1;
temp.mantissa[1] -= 1;
}
temp.sign = 0;
}
if (this->sign == 1 && olong.sign == 1)
{
temp.exponent = this->exponent + olong.exponent;
for (int i = 0; i < 7; i++)
temp.mantissa[i] = this->mantissa[i] + olong.mantissa[i];
if (temp.mantissa[1] > 9)
{
temp.exponent += -1;
temp.mantissa[1] += 1;
}
temp.sign = 1;
}
if (this->sign == 0 && olong.sign == 1)
{
temp.exponent = this->exponent + (-1)*olong.exponent;
for (int i = 0; i < 7; i++)
temp.mantissa[i]= this->mantissa[i] + (-1)*olong.mantissa[i];
if (temp.exponent < 0)
temp.sign = 1;
else
temp.sign = 0;
}
if (this->sign == 1 && olong.sign == 0)
{
temp.exponent = (-1)*this->exponent + olong.exponent;
for (int i = 0; i < 7; i++)
temp.mantissa[i]= (-1)*this->mantissa[i] + olong.mantissa[i];
if (temp.exponent < 0)
temp.sign = 1;
else
temp.sign = 0;
}
return temp;
}
/*LongDouble LongDouble::operator-( LongDouble& olong){}
LongDouble LongDouble::operator*( LongDouble& olong){}
LongDouble LongDouble::operator/( LongDouble& olong)
{
}*/
void LongDouble::print()
{
cout << this->exponent << '.';
for (int i = 0; i < 7; i++)
cout << this->mantissa[i];
}
|
Need to add a copy constructor
thx :) it's solved
Topic archived. No new replies allowed.