Hey guys, I was wondering if you guys could take a look at my code. I am trying to simply implement Bubble Sort, but I am having trouble getting it to compile. I managed to get it to compile and run successfully just using functions in my main file, but when I put my functions into a class and try and run it from a class file. I keep getting these errors:
constint MAX = 10; //the maximum number of elements that the array can hold
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
void RandomArray(int a); //This function will generate random integers in array
void B_Sort(int a, int length); //This function will implement BubbleSort Algo
void PrintSort(int a, int length); //This function will print out Array
};//End BubbleSort Class
#endif /* BUBBLESORT_H */
You didn't include BUBBLESORT.cpp in your project.
And you don't need <cstdlib> in BUBBLESORT.h. Put it in BUBBLESORT.cpp instead.
And never, NEVER put usingnamespace std; in headers. This will make everyone using you library want to brutally murded you.
#include directive executed by preprocessor and basically means "copy-paste all content of <> file here" As you can see there is no way to tell which file should be included to your project. Actually you don't need to name you cpp file accordingly to .h file. You can have 2 cpp files for one .h file or one cpp for two .h.
More: you can compile main.cpp and bubblesort.cpp on two different computers and link them on third, but it is advanced topic :)