This example may give you some ideas how your above code could be re-coded using C++ idioms (and not Java idioms) ...
// insertSortedAryList.cpp //
#include <iostream>
#include <fstream>
//#include <string>
using namespace std;
#define show 0 //set to 1 to turn ON 'showing...'//
const int MAX_ITEMS = 100; // need = at least 13 here ... //
const char* FNAME = "float.txt";
const char* FNAME_OUT = "float_sorted.txt";
/*
10.3 11.2 12.7 0.8 -3.2 11.7 -22.9 -1.1 9.9 -111.1 999 -999 0
*/
typedef float ItemType;
typedef ItemType* iter;
typedef const ItemType* const_iter;
class SortedList
{
public:
SortedList() : length(0) {}
int size() const { return length; }
void clear() { length = 0; }
bool insert( const ItemType& x )
{
//cout << "length = " << length << endl;
int i = 0;
if( length < MAX_ITEMS )
{
if( length )
{
i = findInsertIndexBinSearch( x );
if( i < length )
{
// open up hole at index i
for( int hole = length; hole > i; --hole )
values[hole] = values[hole-1];
}
}
values[i] = x;
}
else
{
cout << "\nList was FULL! NO room to insert!\n";
return false;
}
#if show
cout << " at index[" << i << ']' << endl;
#endif
++length;
return true;
}
bool erase( const ItemType& x )
{
bool wasDeleted = false;
int i = foundAtIndexBinSearch( x );
if( i >= 0 )
{
// copy down over item at index index i
for( int j …