C / C++ Code Portfolio



Download 112,15 Kb.
bet21/30
Sana01.03.2022
Hajmi112,15 Kb.
#475852
1   ...   17   18   19   20   21   22   23   24   ...   30
Bog'liq
dddd

bool operator==(const Array &source) const
{
for (int i = 0; i < SIZE; i++)
{
// if any element of the passed-in array does not match the object array,
// arrays are not equal, return false
if (elements[i] != source[i])
{
return false;
}
}
// all elements of the passed-in array match all elements of the object array, return true
return true;
}

// nonequality operator overloader


bool operator!=(const Array &source) const
{
for (int i = 0; i < SIZE; i++)
{
// if any element of the passed-in array does not match any element of the object array,
// arrays are not equal, return true
if (elements[i] != source[i])
{
return true;
}
}
// all elements of the passed-in array match all elements of the object array, return false
return false;
}

// l-value subscript operator overloader


ElemType &operator[](int index)
{
// check to make sure the index is within range. if not, throw invalid_argument exception
if (index >= SIZE || index < 0)
{
throw invalid_argument("array index is out of range, thrown by L-value overloader");
}
return elements[index];
}

// r-value subscript operator overloader


ElemType operator[](int index) const
{
// check to make sure the index is within range. if not, throw invalid_argument exception
if (index >= SIZE || index < 0)
{
throw invalid_argument("array index is out of range, thrown by R-value overloader");
}
return elements[index];
}

private:
ElemType elements[SIZE];
};
}

#endif // !ARRAY_H



Download 112,15 Kb.

Do'stlaringiz bilan baham:
1   ...   17   18   19   20   21   22   23   24   ...   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