I am trying to work on this assignment I have and I am pretty lost and do not know what to do. Any help would be greatly appreciated.

This is the assignment:
Add two methods (functions) to ex34.

/*
General Info: Write a copy constructor. Use the copy constructor in ex35 as a guide which is :

    MyString(); //default constructor
    MyString(char*); //conversion constructor
    MyString(MyString*); //copy constructor`

Useage: Array myArray(&arrayIn);
pre: arrayIn is a pointer to an existing object of type Array
post: a new object of type Array is created. Its size and contents are identical to those of the argument
/
Array (Array
)

/*
General Info: Write a method the returns a pointer to a sorted copy of invoking object. Use insertion sort as demonstrated in class. It will be easiest to write a stand-alone program to sort
a character array first. Then we'll worry about how to get it to work in class Array.
Useage: Array* sortedCopy = myArray.sort()
pre: ADT exists.
post: returns a pointer to an object of type Array containing the same elements as the invoking object but in order from smallest to largest
/
Array
sort()

Name your work as asgn5.h and asgn5.cpp

Here is the ex34 that is being referenced above:

//class example

#include "ex34.h"
#include <iostream>
   using namespace std;

Array::Array(int sizeIn) 
{
  //cout << "Array constructor" << endl;
  size = sizeIn; 
  array = new char[size];


}

Array::~Array()
{
  //cout << "Array destructor" << endl;
  delete array;
}

char Array::findLargest()
{
 char largest = get(0); 
 for (int i = 1; i < size; i++)
    {
     char item = get(i);
     if (item != '*')
       if (item > largest)
         largest = item;
    }
 return  largest;

}


void Array::insert(int pos, char elt)
{
 array[pos] = elt;
}

void Array::remove(int pos)
{
 array[pos] = '*';
}

int Array::get(int pos)
{
 return array[pos];
}

void Array::display()
{
 for (int i = 0; i < size; i++)
     cout.put(array[i]);
 cout << endl;
}

and the header file:

//A more complex example
#ifndef ARRAY_H
#define ARRAY_H

class Array 
 {
  public:
    /*
    pre:  size is a positive integer
    post: Array of requested size is created with '*' in each slot
    */
    Array(int size);

    ~Array();

    /*
    pre:  ADT exits; 0 <= pos < size; elt is an ascii character; elt != '*'
    post: elt is inserted at position pos
    */
    void insert(int pos, char elt);

    /*
    pre: ADT exists; 0 <= pos < size 
    post: inserts '*' into slot pos
    */
    void remove(int pos);

    /*
    pre:  ADT exists; 0 <= pos < size
    post: returns item in position pos
    */
    int get(int pos); 

    /*
    pre: ADT exists 
    post: displays all elements in the array
    */
    void display();

    /*
    pre: ADT exists 
    post: returns value of largest item. uses function, get
    */
    char findLargest();

  private: 
     int size; 
     char* array; 
 };
#endif

Thanks guys.

Could you please explain what sort of problems you are having with this?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.