mercredi 19 avril 2017

Create a class named Array that represents a safe array

Anyone plz,,                                          
 Create a class named Array that represents a safe array.

1. It has two attribute 2. ptr as an integer pointer for pointer to an integer array. 3. size as an integer number for size of an array.

  1. Make no argument constructor to set size equals to 0 and ptr equals to NULL.
  2. Make one argument constructor, the data type of the argument is int.
  3. Set size equals to the argument value.
  4. Now make array of this size dynamically, and store its address in ptr.
  5. Now fill this array with zeros.

  6. Make two argument constructor, the first argument is an integer array and the 2nd argument is sz.

  7. Set size equals to the sz.
  8. Now make array of this size dynamically, and store its address in ptr.
  9. Fill this array with the array passed through argument.
  10. Make a destructor to free the memory if ptr is not equal to NULL.

  11. Make int Size() function to return array size.

  12. Make int Resize( int newSize) function to resize the array. For this you have to delete the previous array and then make the new array dynamically.

  13. Make void Show() function to show numbers stored in the dynamic array on screen.

  14. Make operator overloading of == operator to see if the two arrays are same or not.
  15. Make operator overloading of += operator to concatenate two arrays objects. Answer should be copied to the calling object.
  16. Hint: You have to resize the array to accommodate two arrays
  17. Make operator overloading of [] operator to read or write any position of the array.
  18. Also write the code to check out of bound errors
  19. Make two Array Objects in main() function and call the above functions and operators.





Comments
0 Comments

0 commentaires:

Enregistrer un commentaire