بي آي أس قيرل
Well-Known Member
- تاريخ التسجيل
- 18 أكتوبر 2010
- المشاركات
- 228
- المجموعة
- أنثى
- الدفعة الدراسية
- 2009
- الكلية
- كلية تقنية المعلومات
حد عنده جواب دي السؤال ؟
Question 4 (24 Points)
Consider the class TList given below:
class TList
{
private:
int * dynamicArr; //Pointer to a dynamic Array
int MaxSize; // Maximum Size of the dynamic array
int arrSize; // Actual Size of the dynamic array
public:
TList (int MaximumSize = 30);
void insertLast(int item) // Inserts item as the last
element in dynamicArr and increments arrSize
~ TList ();
}; // end class TList
(Part A) [6 Points]
Rewrite the above class as a template class so that it becomes a List of any type T (not just of
integers).
(Part B)[4 Points]
Write the implementation of the constructor function that initializes MaxSize to the value of
the parameter MaximumSize, initializes ArrSize to 0 and creates the
dynamic array dynamicArr of the given MaxSize.
Page 6 of 9
Question (4) Continue
(Part C)[4 Points]
Write the implementation of the destructor function.
(Part D)[6 Points]
Write the implementation of the insertLast function that receives an item of any type and
inserts it as the last element of the array dynamicArr and increments the
actual size of the array. The function should check first to
make sure that the actual size of the array will not exceed
the maximum size allowed.
(Part E)[4 Points]
1. Write a statement to define an object named myGrades of type class TList, where the
list will be of type double, and its maximum size is 50.
2. Write a statement to insert the value of 52.5 to the list myGrades defined above.
3. Write a statement to define an object named myNames of type class TList, where the
list will be of type String, and its maximum size is 20.
4. Write a statement to insert the name Ahmad to the list myNames defined above.
Question 4 (24 Points)
Consider the class TList given below:
class TList
{
private:
int * dynamicArr; //Pointer to a dynamic Array
int MaxSize; // Maximum Size of the dynamic array
int arrSize; // Actual Size of the dynamic array
public:
TList (int MaximumSize = 30);
void insertLast(int item) // Inserts item as the last
element in dynamicArr and increments arrSize
~ TList ();
}; // end class TList
(Part A) [6 Points]
Rewrite the above class as a template class so that it becomes a List of any type T (not just of
integers).
(Part B)[4 Points]
Write the implementation of the constructor function that initializes MaxSize to the value of
the parameter MaximumSize, initializes ArrSize to 0 and creates the
dynamic array dynamicArr of the given MaxSize.
Page 6 of 9
Question (4) Continue
(Part C)[4 Points]
Write the implementation of the destructor function.
(Part D)[6 Points]
Write the implementation of the insertLast function that receives an item of any type and
inserts it as the last element of the array dynamicArr and increments the
actual size of the array. The function should check first to
make sure that the actual size of the array will not exceed
the maximum size allowed.
(Part E)[4 Points]
1. Write a statement to define an object named myGrades of type class TList, where the
list will be of type double, and its maximum size is 50.
2. Write a statement to insert the value of 52.5 to the list myGrades defined above.
3. Write a statement to define an object named myNames of type class TList, where the
list will be of type String, and its maximum size is 20.
4. Write a statement to insert the name Ahmad to the list myNames defined above.