So I'm writing a sample solution for the intro to programming class I'm TAing, and this problem crops up:
namespace PStar
{
void bubbleSort(int sort[], const int size)
{
assert(size >0);
int max, i;
for(max = size-2; max>0; max--)
{
for(i = 0; i < max; i++)
{
if (sort[i]>sort[i+1]) intSwap(sort[i], sort[i+1]);
}
}
}
/*much more code*/
void intSwap(int &a, int &b)
{
int temp;
temp = a;
a = b;
b = temp;
return;
}
}//end of namespace
When I try to compile I get the following error message:
error C2065: 'intSwap' : undeclared identifier
there is no doubt a simple screw-up on my behalf amongst the things I think I've ruled out:
I've counted curly braces
Everything is declared properly in the corresponding header file
Furthermore, intSwap works fine when called in main.
among things I can't do to solve the problem:
call the STL swap function (the minions haven't learned about templating yet)
Any suggestions as to what I may have screwed up would be very appreciated, thanks! |