Hi everyone. I'm trying to, currently, learn how to effectively use .h and .cpp files separately. I'm using a bubblesort program I wrote to get me started but I'm stuck!
I get this error in Xcode now, after chopping up my code:
error: no matching function for call to 'mySort::bubbleSort(const char* [2000])'
It sounds simple enough, my functions don't match. My program also used to work with all the code in one file. I would greatly appreciate any help on this as I'm not very fluent in C++ yet.
I had to delete my previous faux-success post. I compiled another project thinking it was the one we're talking about.
I tried the suggestion to put this in mySort.h :
void bubbleSort(const char *names[], const int length = 2000);
I get this new strange error in Xcode:
Command /Developer/usr/bin/g++-4.0 failed with exit code 1
or when I copy and paste the error in here:
collect2: ld returned 1 exit status
Update: Searched around the net and apparently this is a linker error and not a compiler one. My first program with many surprises :)
If I remember correctly (I'm not in front of my Mac at the moment), in XCode you must make sure that your .cpp files are listed under the "Compile Sources" phase of your "Target".
If they're not you need to add them (just dragging them should suffice). If not, they won't be compiled so the linker won't find the .o file. There should also be a small radio button in the top pane of the editor window next to the filename which should do the same thing.