Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have a problem about my code here is my code below: //this is the header file:

ID: 643125 • Letter: I

Question

I have a problem about my code

here is my code below:

//this is the header file:

#include <stdio.h>

#include<iostream>

using namespace std;

static int numberOfElements =30;

template<class T>

class Array

{

public:

  

Array();

~Array();

int getSize()const;

bool operator!= (const Array&)const;

T& operator[](int);

int getNumberOfElementInArray()const;

void readElements();

void displayElements()const;

bool operator==(const Array& otherArray) const;

private:

T elements;

int elementInArray;

int numberOfElements;

};

//this is the implement file:

#include "Array.h"

template<class T>

Array<T>::Array()

{

elements = new T[numberOfElements];

}

template<class T>

Array<T>::~Array()

{

delete elements;

}

template<class T>

int Array<T>::getSize() const

{

return numberOfElements;

}

template<class T>

bool Array<T>::operator==(const Array&otherArray)const

{

if(getSize() != otherArray.getSize())

return false;

for(int i=0;i<numberOfElements;i++)

{

if(elements[i]!=otherArray.elements[i])

return false;

}

return true;

}

template<class T>

bool Array<T>::operator!=(const Array&otherArray)const{

for(int i=0;i<numberOfElements;i++)

{

if(elements[i]!=otherArray.elements[i])

return true;

}

return false;

}

template<class T>

T& Array<T>::operator[](int size)

{

return elements[size];

}

template<class T>

int Array<T>::getNumberOfElementInArray() const

{

return elementInArray;

}

template<class T>

void Array<T>::readElements()

{

for(int i =0;i<numberOfElements;i++)

{

cin>>elements[i];

elementInArray++;

  

}

}

template<class T>

void Array<T>::displayElements() const

{

int i;

for(i = 0;i<getSize();i++)

{

cout<<elements[i]<<" ";

if((i+1)%15==0)

cout<<endl;

}

if((i+1)%15!=0)

cout<<endl;

}

// here is the main file:

#include "Array.h"

#include <stdio.h>

#include<iostream>

using namespace std;

int main()

{

string msg;

Array<int> arrayOfIntegers;

Array<string> arrayOfStrings;

cout<<"enter"<<arrayOfIntegers.getSize()<<"integer values:"<<endl;

arrayOfIntegers.readElements();

cout<<"Enter"<<arrayOfStrings.getSize()<<"string values:"<<endl;

arrayOfStrings.readElements();

cout<<"The elements stored in the string array are:"<<endl;

arrayOfStrings.displayElements();

Array<int> arrayOfIntegers1;

  

cout<<"enter"<<arrayOfIntegers.getSize()<<"integer values to new integer array"<<endl;

arrayOfIntegers1.readElements();

if(arrayOfIntegers == arrayOfIntegers1)

{

msg = "Yes";

}

else

msg = "no";

cout<<"Are two int arrays the same(0 f 1 t)?"<<msg<<endl;

cout<<"Are two int arrays not the same(0 f 1 t)?"<<msg<<endl;

cout<<"value stored in the 5th edition in the"<<"int array:"<<arrayOfIntegers[5]<<endl;

arrayOfIntegers[5]=9999;

cout<<"Value stored in the int array ager"<<"updating 6th value with 9999"<<endl;

arrayOfIntegers.displayElements();

return 0;

}

The problem is in the header file

int getNumberOfElementInArray()const; the error is unknown type name elementType

void readElements();   the error is unknown type name elementtype

T elements; the error is "use of undeclared identifier numberOfEelements"

there's also a probem in my main:

the problem is

msg = "Yes"; the error is invalid opernd to binary expression("Array" and "Array")

I have to submit it tmr so it is really emergent. I would appreciate it if someone could help me

Explanation / Answer

You are almost there but you did a smal mistake you forgor to include

Array.h header. above the main method but you included it in implememtation

try once keeping header on top ...