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--)
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.