I need help with the functions: is_duplicate and remove_all to work for my assignemt. Here is the code, been trying to get it to work for the past two hours. Any help would be nice
<code>
#include <iostream>
using std::cout; using std::cin; using std::endl;
class MyList
{
private:
const static int INC = 10;
const static int DCAP = 20;
int *a;
int csz;
int cap;
bool move();
MyList::MyList()
{
//cout << "Default constructor is called." << endl;
csz = 0;
a = new int[DCAP];
if (a == nullptr)
cout << "failed!!" << endl;
cap = DCAP;
}
MyList::MyList(int ucap)
{
//cout << "Parameterized constructor is called." << endl;
csz = 0;
if (ucap <= 0)
cap = DCAP;
else
cap = ucap;
a = new int[cap];
}
bool MyList::present(int v)
{
for (int i = 0; i < csz; ++i)
if (a[i] == v)
return true;
return false;
}
bool MyList::remove_all()
{
int number;
cin >> number;
cout << "Please enter duplicates" << number << "that are found";
for (int i= 0; i= csz; i++)
{
if (number == a[i])
{
for (int n= i; n < csz-1; ++n)
{
a[n]=a[i+1];
}
csz= csz-1;
}
}
}
void MyList::erase()
{
cout << "Array being erased now fucker";
for (int i =0; i < csz; i++)
{
a[i]=0;
}
}
int MyList::is_duplicate(int v)
{
int count = 0;
for(int i=0; i< csz ; i++)
{
int v;
if(a[i]==v)
{
count++;
}
}
return count;
}
int main()
{
MyList l1;
l1.clt();
//memory all MyListocated dynamicall
l1.display();
cout << "lets find the duplicates:";
l1.is_duplicate(int v);
cout <<"would you like to remove duplicates? Put 1 for yes, 2 for nah:";
int input;
cin >> input;
if (input == 1)
{
l1.remove_all();
}
else if (input == 2)
{
cout << "Okay have fun!:";
l1.erase();
}