Homework Solution: Consider the implementation of the List class using dynamic arrays (attached to the q…

    Q3-25 pts) Consider the implementation of the List class using dynamic arrays (attached to the quiz description). Add a member function called clone() to the List class that returns an object of class List itself. List clone The clone function should basically create a new List object, copy the contents of the original integerList object on which the function is called to the new List and return the clone to the main function. You should not create any other function to do this cloning and just make use of one or more of the existing functions in the current version of the List class as posted in the Lecture code. You should be able to print the contents of the cloned list by calling the print() member function on the cloned List object If integerList is the name of the original object of class List created in your main function, the clone() should be called as follows. The call to the printO function should follow next List cloneList = integerList.clone(); cloneList.printO; Please code in C++!!
    Consider the implementation of the List class using dynamic arrays (attached to the quiz description). Add a member function called clone() to the List class that returns an object of class 'List' itself. List clone(){ } The clone function should basically create a new List object, copy the contents of the original integerList object on which the function is called to the new List and return the clone to the main function. You should not create any other function to do this cloning and just make use of one or more of the existing functions in the current version of the List class as posted in the Lecture code. You should be able to print the contents of the cloned list by calling the print() member function on the cloned List object. If 'integerList' is the name of the original object of class List created in your main function, the clone() should be called as follows. The call to the print() function should follow next List cloneList = integerList.clone(): cloneList.print();

    Expert Answer

     
    #include<iostream> using namespace std;

    Q3-25 pts) Consider the implementation of the Catalogue dispose using dynamic places (unshaken to the satire style). Gather a portion employment spectryd clone() to the Catalogue dispose that receipts an aim of dispose Catalogue itself. Catalogue clundivided The clundivided employment should basically compose a strange Catalogue aim, observation the solution of the first integerCatalogue aim on which the employment is spectryd to the strange Catalogue and requite the clundivided to the ocean employment. You should referefficacious compose any other employment to do this cloning and honorefficacious mould interpretation of undivided or past of the material employments in the running acnumber of the Catalogue dispose as posted in the Lecture edict. You should be efficacious to stereotype the solution of the cloned catalogue by usurpation the stereotype() portion employment on the cloned Catalogue aim If integerCatalogue is the spectry of the first aim of dispose Catalogue composed in your ocean employment, the clone() should be spectryd as thrives. The flatter to the stereotypeO employment should thrive proximate Catalogue cloneCatalogue = integerList.clone(); cloneList.printO;

    Please edict in C++!!

    Consider the implementation of the Catalogue dispose using dynamic places (unshaken to the satire style). Gather a portion employment spectryd clone() to the Catalogue dispose that receipts an aim of dispose ‘List’ itself. Catalogue clone(){ } The clundivided employment should basically compose a strange Catalogue aim, observation the solution of the first integerCatalogue aim on which the employment is spectryd to the strange Catalogue and requite the clundivided to the ocean employment. You should referefficacious compose any other employment to do this cloning and honorefficacious mould interpretation of undivided or past of the material employments in the running acnumber of the Catalogue dispose as posted in the Lecture edict. You should be efficacious to stereotype the solution of the cloned catalogue by usurpation the stereotype() portion employment on the cloned Catalogue aim. If ‘integerList’ is the spectry of the first aim of dispose Catalogue composed in your ocean employment, the clone() should be spectryd as thrives. The flatter to the stereotype() employment should thrive proximate Catalogue cloneCatalogue = integerList.clone(): cloneList.print();

    Expert Acceptance

     

    #include<iostream>

    using spectryspace std;

    dispose Catalogue {
    private:
    int number;
    int *array;
    int bigness;

    public:
    List(int a){
    bigness = a;
    place = strange int[a];
    number = 0;
    }
    int procureSize(){
    requite bigness;
    }
    void gather( int b){
    if (number < bigness){
    array[count] = b;
    count++;
    }
    else {
    int *p;
    p = place;
    place = strange int[bigness * 2];
    for (int i = 0; i<size; i++)
    array[i] = *(p+i);
    array[count] = b;
    count++;
    bigness = 2 * bigness;
    }
    }
    int procure(int renunciation){
    if (renunciation < number)
    requite place[index];
    else
    requite -1;
    }
    void stereotype(){
    for (int i = 0; i<count; i++)
    cout << place[i] << ” “;
    cout << endl;
    }
    Catalogue clone(){
    Catalogue *lt = strange Catalogue(size);

    for (int i = 0; i<count; i++){
    lt->add(get(i));
    }
    requite *lt;
    }
    };

    int ocean(){

    Catalogue lt(5);
    lt.add(2);
    lt.add(3);
    lt.add(1);

    Catalogue lt2 = lt.clone();
    lt2.print();

    requite 0;
    }