Selesai

c++ problem involving pointers and classes

Proyek ini berhasil diselesaikan oleh kostasrim dengan harga $30 USD dalam sehari.

Dapatkan penawaran gratis untuk proyek seperti ini
Pemberi kerja bekerja
Anggaran Proyek
$10 - $30 USD
Diselesaikan Dalam
1 hari
Total Penawaran
4
Deskripsi Proyek

Need done in less than an hour!

Use the following code segment for your answers to the questions below:

template< class T >

class Mystery

{   public:

    private:

       T *what1;

       T *what2;

       int size;  // The size is for the two arrays(what1 and what2).

};

int main( )

{   const int SIZE = 5;

   int grades1[ ] = { 100, 90, 87, 89, 60}; // LINE 1

   int grades2[ ] = { 98,56,90,90,100}; //LINE 2

   Mystery < int > object1( grades1, grades2, SIZE); // LINE 3

   cout << object1[3] << endl; // LINE 4

   return 0;

}

Questions:

1. The code on LINE 3 in the main is supposed to copy all array elements of grades to the *what that is used as an array.   ( 5 points)

What is missing in the class Mystery? Come up with the implementation inside the class.

2. Come up with the implementation inside the class to make the code on LINE 4 work when executed in a complete program.  (3 points)

3. Where should you delete the pointers of the class?  Modify the class.  (2 points)

4.  What should be done to the main ( ) if the main contains the following statement below LINE4 ?   ( 2 points)

   Mystery < double > object2( grades4, grades5, SIZE);

Diselesaikan oleh:
Keahlian yang Diperlukan

Ingin menghasilkan uang?

  • Atur anggaran Anda dan jangka waktunya
  • Uraikan proposal Anda
  • Dapatkan bayaran atas pekerjaan Anda

Pekerjakan para freelancer yang juga menawar di proyek ini

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online