redefinition of int main() c++ : <p>Compiler constantly give the error redefine of int main(). I don't know where is the problem. There is also problem with MAX_CHAR. It's writtend MAX_CHARS’ was not declared in this scope. Any suggeston, comment ?? </p>

<pre><code>#include &lt;iostream&gt; // cin cout endl
#include &lt;fstream&gt; // ifstream
#include &lt;sstream&gt; // stringstream
#include &lt;stdlib.h&gt; //exit
#include "insertionSort.h"
#include &lt;vector&gt;
#include &lt;climits&gt;

using std::cerr;
using std::cout;
using std::endl;
using std::ifstream;

const int MAX_CHAR = 500; // max length of each line to read from the input file

template&lt;class T&gt;
void readSortOutput( char* typeName, vector&lt;T&gt; v, ifstream &amp;inStream );

int main()
{
    cout &lt;&lt; "Insertion sort algorithm driver program" &lt;&lt; endl;

    ifstream inStream("/home/Downloads/input.txt");
    if( inStream.fail( ) )
    {
        cerr &lt;&lt; "Input file opening failed.\n";
        exit(1);
    }

    vector&lt;int&gt; intVector;
    readSortOutput( (char*)"int", intVector, inStream );

    vector&lt;double&gt; dblVector;
    readSortOutput( (char*)"double", dblVector, inStream );

    inStream.close( );

    return 0;
}

template&lt;class T&gt;
void insertionSort(vector&lt;T&gt;&amp; data)
{
    for (size_t i = 0; i &lt; data.size( ); i++)
        for (size_t j = i; j &lt; data.size( ); j++)
            if (data[ j ] &lt; data[ i ])
            { // swap values
                T temp = data[ j ];
                data[ j ] = data[ i ];
                data[ i ] = temp;
            }

    return;
}

template&lt;class T&gt;
void readSortOutput( char* typeName, vector&lt;T&gt; v, ifstream &amp;inStream )
{

    char fileLine[MAX_CHARS];
    std::stringstream ss;
    inStream.getline(fileLine, MAX_CHARS);
    ss &lt;&lt; fileLine;
    T elem;
    while (ss &gt;&gt; elem) {
        v.push_back( elem );
    }

    cout &lt;&lt; endl &lt;&lt; typeName &lt;&lt; " vector before insertion sort: " &lt;&lt; endl;
    for (int i = 0; i &lt; v.size( ); i++)
        cout &lt;&lt; v[i] &lt;&lt; " ";
    cout &lt;&lt; endl;

    insertionSort( v ); // the sort itself

    cout &lt;&lt; typeName &lt;&lt; " vector after insertion sort: " &lt;&lt; endl;
    for (int i = 0; i &lt; v.size( ); i++)
        cout &lt;&lt; v[i] &lt;&lt; " ";
    cout &lt;&lt; endl;

    return;
}
</code></pre>

<p>InsertionSort.h</p>

<pre><code>#ifndef INSERTIONSORT_H
#define INSERTIONSORT_H
#include &lt;iostream&gt;

#include &lt;iostream&gt; // cin cout endl
#include &lt;fstream&gt; // ifstream
#include &lt;sstream&gt; // stringstream
#include &lt;stdlib.h&gt; //exit
#include "insertionSort.h"
#include &lt;vector&gt;
#include &lt;climits&gt;

using namespace std;

int main()
{
    int sizee=10;
    int v[sizee];
    for (int i=0;i&lt;sizee;i++){
         cout&lt;&lt;"Sorting array:  ";
        cin&gt;&gt;v[i];
    }
    int i,j,val;
    for (i=1; i&lt;sizee; i++) {
        val=v[i];
        j = i-1;
        while (j&gt;=0 &amp;&amp; v[j]&gt;val) {
            v[j+1] = v[j];
            j--;
        }
        v[j+1] = val;
    }
    for (int i=0;i&lt;sizee;i++){
        cout&lt;&lt;"v["&lt;&lt;i&lt;&lt;"]="&lt;&lt;v[i]&lt;&lt;endl;
    }
    return 0;
}
</code></pre>
