C / C++ Code Portfolio


return Complex(real - other.real, imaginary - other.imaginary); } // == operator overloader bool



Download 112,15 Kb.
bet16/30
Sana01.03.2022
Hajmi112,15 Kb.
#475852
1   ...   12   13   14   15   16   17   18   19   ...   30
Bog'liq
dddd

return Complex(real - other.real, imaginary - other.imaginary);
}

// == operator overloader


bool ChrisBerger::Complex::operator==(const ChrisBerger::Complex &other) const
{
return (other.real == real) && (other.imaginary == imaginary);
}

// != operator overloader


bool ChrisBerger::Complex::operator!=(const ChrisBerger::Complex &other) const
{
return !(other.real == real) && (other.imaginary == imaginary);
}

// << operator overloader


ostream &ChrisBerger::operator<<(ostream &out, const ChrisBerger::Complex &value)
{
// declare a temporary Complex
Complex *temp = new Complex(value.real, value.imaginary);
// output the real component
out << temp->real;
// if the imaginary component is negative...
if (temp->imaginary < 0)
{
// negate the imaginary component and output a minus-sign
temp->imaginary *= -1;
out << "-";
}
// if the imaginary component is positive, output a positive-sign
else
{
out << "+";
}
// output the "i"
out << temp->imaginary << "i";
// delete the temporary variable
delete temp;
return out;
}

// >> operator overloader


istream &ChrisBerger::operator>>(istream &in, ChrisBerger::Complex &value)
{
// declare a temporary charcter
char temp;
// declare doubles for the real and imaginary components
double tempReal, tempImaginary;
// read in the real component, this may include a minus-sign for a negative real component
in >> tempReal;
// set the real component of the Complex to the read in real component
value.real = tempReal;
// read in the sign of the imaginary component

Download 112,15 Kb.

Do'stlaringiz bilan baham:
1   ...   12   13   14   15   16   17   18   19   ...   30




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish