The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

no doubt needlessly stupid question by NedLudd 2002-11-02 19:59:24
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!
[ Reply ]
  declare intSwap before bubbleSort (n/t) by kahuana2002-11-02 20:01:11
    IDENTICAL submits! by borg3892002-11-02 20:02:23
      But mine's lower down. by kahuana2002-11-02 20:04:26
        Heheheh. by borg3892002-11-02 20:13:17
  declare intSwap before you use it by borg3892002-11-02 20:01:53
  you have a return in a void function. by BlurOfSerenity2002-11-02 20:04:01
    Doesn't matter by borg3892002-11-02 20:11:31
  So does it work now? (n/t) by borg3892002-11-02 20:35:07
    indeed it does by NedLudd2002-11-02 21:21:43
      No stupid questions by borg3892002-11-02 21:29:26
        another good one... by NedLudd2002-11-02 21:35:08

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)