Answer to Question #249085 in C++ for Morena

Question #249085

An arrayList is one of the most important data structures used in many applications.


Define and show the implementation of the functions of an arrayList.


1
Expert's answer
2021-10-09T15:51:02-0400
#include <iostream>


using namespace std;


template <typename TElement>
class stackInArray {
private:
    unsigned int sizeOfStack;
    TElement* array;


public:
    stackInArray(const unsigned int maxSize) {
        sizeOfStack = 0;
        array = new TElement[maxSize];
    }


    ~stackInArray() {
        delete[] array;
    }


    void push(const TElement newElement) {
        array[sizeOfStack] = newElement;
        sizeOfStack++;
    }


    void pop() {
        sizeOfStack--;
    }


    TElement top() {
        return array[sizeOfStack - 1];
    }


    unsigned int size() {
        return sizeOfStack;
    }
};


int main(int argc, char** argv) {
	
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS