error LNK 2005... struct already defined....Please help

I'm getting this error...
1>drive.obj : error LNK2005: "struct info h" (?h@@3Uinfo@@A) already defined in BubbleSort.obj
1>HeapSort.obj : error LNK2005: "struct info f" (?f@@3Uinfo@@A) already defined in drive.obj
1>InsertionSort.obj : error LNK2005: "struct info e" (?e@@3Uinfo@@A) already defined in drive.obj
1>MergeSort.obj : error LNK2005: "struct info g" (?g@@3Uinfo@@A) already defined in drive.obj
1>QuickSort.obj : error LNK2005: "struct info d" (?d@@3Uinfo@@A) already defined in drive.obj
1>SelectionSort.obj : error LNK2005: "struct info c" (?c@@3Uinfo@@A) already defined in drive.obj
1>drive.obj : error LNK2001: unresolved external symbol "public: static int info::count" (?count@info@@2HA)
1>drive.obj : error LNK2001: unresolved external symbol "public: static int info::counter" (?counter@info@@2HA)
\Project-5.exe : fatal error LNK1120: 2 unresolved externals.


And I believe this is the cleanest it has looked after the twelve hours I spent today... i have diff. files and in this post i'll separate them with ****...
P.S I don't think the problem is the sort alg because I already used them with a different drive.cpp and worked fine...Although I added a few things for this drive file I should mention that i'm trying to test the performance of this ALGorithms by calculating how many times they use swap and compare elements... I also started getting this error using the "show()" but i may be wrong. so here they go:
*****************performance.h
#ifndef PERFORMANCE_H
#define PERFORMANCE_H

#include <iostream>

using namespace std;

struct info{
static int count;
static int counter;

void comprCount(){

count = 0;
count += 1;
}

void swpCountr(){

counter = 0;
counter += 1;
}

};

#endif

**********************BubbleSort.cpp
#include "performance.h"
info h;

template<class ItemType>
void BubbleUp (ItemType values[], int startIndex, int endIndex, bool& sorted){
sorted = true;
for (int index = endIndex; index > startIndex; index--)

if (values[index] < values[index-1])
{
Swap(values[index], values[index-1]);
h.swpCountr();
sorted = false;
}
}

template<class ItemType>
void BubbleSort (ItemType values[], int numValues){
int current = 0;
bool sorted = false;
while (current < numValues - 1 && !sorted)
{
BubbleUp(values, current, numValues-1, sorted);
h.comprCount();
current++;
}
}

*********************SelectionSort.cpp
#include "performance.h"
info c;

template<class ItemType>
inline void Swap(ItemType& item1, ItemType& item2){

ItemType tempItem;

tempItem = item1;
item1 = item2;
item2 = tempItem;
}

template <class ItemType>
int MinIndex (ItemType values[], int startIndex, int endIndex){

int indexOfMin = startIndex;
for( int index = startIndex + 1; index <= endIndex; index++)

if (values[index] < values[indexOfMin])
{
indexOfMin = index;
c.comprCount();
}
return indexOfMin;
}

template<class ItemType>
void SelectionSort (ItemType values[], int numValues){

int endIndex = numValues-1;
for (int current = 0; current < endIndex; current++)
{
Swap(values[current], values[MinIndex(values, current, endIndex)]);
c.swpCountr();
}
}
****************InsertionSort.cpp
#include "performance.h"

info e;

template<class ItemType>
void InsertItem(ItemType values[], int startIndex, int endIndex){

bool finished = false;
int current = endIndex;
bool moreToSearch = (current != startIndex);

while (moreToSearch && !finished)
{ e.comprCount();
if (values[current] < values[current-1])
{
Swap(values[current], values[current-1]); e.swpCountr();
current--;
moreToSearch = (current != startIndex);
}
else
finished = true;
}
}

template<class ItemType>
void InsertionSort(ItemType values[], int numValues){

for ( int count = 0; count < numValues; count++)
InsertItem(values, 0, count);
}

*********************QuickSort.cpp
#include "performance.h"

info d;

template<class ItemType>
int Split(ItemType arr[], int first, int last)
{
int i = first, j = last;
int pivot = arr[(first + last) / 2];

while (i <= j)
{ d.comprCount();
while (arr[i] < pivot)
i++;

while (arr[j] > pivot)
j--;
if (i <= j)
{
Swap(arr[i], arr[j]); d.swpCountr();
i++;
j--;
}
}
return i;
}


template <class ItemType>
void QuickSort(ItemType arr[], int left, int right){

int index = Split(arr, left, right);
if (left < index - 1)
QuickSort(arr, left, index - 1);
if (index < right)
QuickSort(arr, index, right);
}

***************drive.cpp
#include "BubbleSort.cpp"
#include "InsertionSort.cpp"
#include "SelectionSort.cpp"
#include "QuickSort.cpp"
#include "MergeSort.cpp"
#include "HeapSort.cpp"
#include "performance.h"


using namespace std;

void show();

int main(){
int a [100];
int b [1000];

for (int i = 0; i < 100; i++)
a[i] = rand();
for (int i = 0; i < 1000; i++)
b[i] = rand();

BubbleSort(a, 100);
InsertionSort(a, 100);
SelectionSort(a, 100);
QuickSort(a, 0, 99);
MergeSort(a, 0, 99);
HeapSort(a, 100);

show();
}

void show(){
cout << "BubbleSort: '\n' comparisons: "<< h.count<< "\n Swaps: " << h.counter << endl;
cout << "InsertionSort: '\n' comparisons: "<< c.count << "\n Swaps: " << c.counter << endl;
cout << "SelectionSort: '\n' comparisons: "<< d.count << "\n Swaps: " << d.counter << endl;
cout << "QuickSort: '\n' comparisons: "<< e.count << "\n Swaps: " << e.counter << endl;
cout << "MergeSort: '\n' comparisons: "<< f.count << "\n Swaps: " << f.counter << endl;
cout << "HeapSort: '\n' comparisons: "<< g.count << "\n Swaps: " << 0 << endl;

}

I didn't include the last two sort Algorithms but it's the same idea. Plus like I mentioned before they work. The parts in Bold are the new things I added.
THank you very much any help would be greatly appreciated.

PS> one more thing i did another version of this program, but instead of performance.h i declared global variables and use the increment operator(++) instead of swpcounter() and comprcount(), but I had the same results. same error is what I mean.
Topic archived. No new replies allowed.