math lover
اا مشرف سابق اا
- تاريخ التسجيل
- 28 سبتمبر 2009
- المشاركات
- 2,472
- المجموعة
- أنثى
- الدفعة الدراسية
- 2009
- الكلية
- كلية العلوم
- التخصص
- math-biology
بس السؤال طالب تو دايمنشن اريه
بس الاري الثاني ما يكون بوينر صح لو اني فاهمة خطأ؟
بس السؤال طالب تو دايمنشن اريه
الحين نحط بوينتر اولا؟؟
لانه حلته ويانا الدكتورة هالسؤال بدون بوينتر بس الاول ؟؟
template<class t>
class TList
{
private:
t * dynamicArr;
int MaxSize;
int arrSize;
public:
TList (int MaximumSize = 30);
void insertLast(t item);
~ TList ();
};
template<class t>
Tlist<t>::Tlist(int MaximumSize)
{ MaxSize=MaximumSize;
arrSize=0;
dynamicArr=new t[MaxSize];
}
template<class t>
Tlist<t>::~ Tlist()
{ delete[]dynamicArr;
dynamicArr=NULL;
}
template<class t>
void Tlist<t>::insertLast(t item)
{
if(arrSize<MaxSize)
{ dynamicArr[arrSize]=item;
arrSize++;
}
}
اي سوري بس لانه من التيلفون مصورتنه فصايره الصورة صغيرة كبرتها بس بعد تطلع صغيرة
bool TDate::operator<(const TDate& obj)const
{
if(year<obj.year)
return true;
else if (year==obj.year && month<obj.month)
return true;
else if (year==obj.year && month==obj.month && day<obj.day)
return true;
else
return false;
}
bool operator==(const TDate& obj1,const TDate& obj2)
{
return(obj1.year==obj2.year && obj1.month==obj2.month && obj1.day==obj2.day)
}
int main()
{
TDate D1(12,12,1998);
TDate D2(25,1,1999);
if(D1<D2)
cout<<"D1="<<D1.print()<<"is before D2="<<D2.print();
else if (D1==D2)
cout<<"D1="<<D1.print()<<"is the same as D2="<<D2.print();
else
cout<<"D1="<<D1.print()<<"is after D2="<<D2.print();
}
int Rightdigit(int n, int k)
{
if(k==0)
return (n%10);
else
{
n=(n/10);
return Rightdigit(n,k-1);
}
}
هذي الصورة من جديد
![]()
Consider the class TDate given below:
class TDate
{
private:
int Day; // 1-30 only
int Month; // 1-12 only
int Year;
public:
TDate(int D = 1, int M = 1, int Y = 1900);
Print(); //Prints the date in dd/mm/yyyy format;
……
}; // end class TDate
(Part A)
Overload the operator < (less than) as a member function of the class TDate, so that :
D1 < D2 will return true if the if the Date D1 is before the date D2.
Note that D1 is before D2 if the year of D1 is less then year of D2 or
If years are the same but the month of D1 is less then month of D2
Or if the months and years are the same but Day of D1 is less then Day
of D2
Otherwise, it returns false.
الحل
PHP:bool TDate::operator<(const TDate& obj)const { if(year<obj.year) return true; else if (year==obj.year && month<obj.month) return true; else if (year==obj.year && month==obj.month && day<obj.day) return true; else return false; }
(Part B)
Overload the = operator (equal) as a non-member function of the class TDate, so that :
L1 == L2 will return true if the Dates D1 and D2 are the same.
Otherwise, it returns false.
PHP:bool operator==(const TDate& obj1,const TDate& obj2) { return(obj1.year==obj2.year && obj1.month==obj2.month && obj1.day==obj2.day) }
Question (5) Continue
(Part C)
Write a main function that declares two dates: (Example D1 as12/12//1998 and D2 as
25/1/1999) And prints one of the following messages as appropriate:
D1 = dd/mm/yyyy is before D2 = dd/mm/yyyy
D1 = dd/mm/yyyy is the same as D2 = dd/mm/yyyy
D1 = dd/mm/yyyy is after D2 = dd/mm/yyyy
PHP:int main() { TDate D1(12,12,1998); TDate D2(25,1,1999); if(D1<D2) cout<<"D1="<<D1.print()<<"is before D2="<<D2.print(); else if (D1==D2) cout<<"D1="<<D1.print()<<"is the same as D2="<<D2.print(); else cout<<"D1="<<D1.print()<<"is after D2="<<D2.print(); }
لان الفنكشن وظيفتها تقارن وتطلع لينا ترو اور فولس