The compiler only displays a portion of the output and then it exits this is what it compiles:
===============================================
Operations on Empty lists:
===============================================
Size = -886911509
Length = 0
empty list:
Sum of two empty lists:
Program received signal: “EXC_BAD_ACCESS”.
sharedlibrary apply-load-rules all
stringlist(2449) malloc: *** error for object 0x1001002d8: incorrect checksum for freed object - object was probably modified after being freed.
this is the .cpp file
#include <iostream>
#include <string>
#include <cstdio>
#include "stringlist.h"
using namespace std;
StringList::StringList( int size )
{ int value;
size=10;
this->size=size;
this->size=value;
data = new string[size];
for (int i =0; i< size; i++)
{
data [i] = value;
}
}
StringList:: StringList( const StringList &list2 )
{
size = list2.size;
data = new string[size];
if(data!=NULL)
{
for (int i=0; i<size; i++) {
data[i]=list2.data[i];
}
}
}
StringList& StringList::operator=( const StringList &list_2 )
{
if ( this != &list_2 )
{
delete[]data;
data = new string[size];
size=list_2.size;
}
for (int i = 0; i<size; i++)
{
data[i]=list_2.data[i];
}
return *this;
}
StringList::~StringList()
{
delete[] data;
}
int StringList:: askSize() const
{
return size;
}
int StringList::askLength() const
{
int length=0;
return length;
}
void StringList::addToFront( string s1 )
{
string value;
value=s1;
data=new string[size];
for(int ii=0; ii < size; data[ii++])
s1 = value;
}
void StringList:: insert( string s1, int pos )
{
data = new string[size];
for(int ii=0; ii < size; data[ii++])
s1= pos;
}
void StringList::append( string s1 )
{
for(int ii=0; ii < size; ++ii)
{
data[ii]= s1;
}
}
void StringList:: remove( string s1 )
{
delete data;
size=0;
data=NULL;
}
void StringList::remove( int pos )
{
delete data;
pos=0;
data=NULL;
}
int StringList::find( string s1 ) const
{
int index;
if(index >= 0 && index < size)
{
data[index] = s1;
}
}
void StringList::print( ) const
{
int start_index;
int end_index ;
if (start_index >= 0 && end_index < size)
{
for (int i = start_index; i <= end_index; i++)
cout << i << "," << data[i]<< ")"<< endl;
}
}
StringList StringList:: operator+( const StringList &list_2 ) const
{
return StringList(size+list_2.size);
}
StringList StringList:: operator-( const StringList &list_2 ) const
{
return StringList(size-list_2.size);
}
bool StringList:: operator==( const StringList &list_2 ) const
{
return (size==list_2.size);
}
bool StringList:: operator!=( const StringList &list_2 ) const
{
return (size!=list_2.size);
}