Click here to Skip to main content
15,912,329 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Unhandled exception... Pin
Renjith Ramachandran14-May-02 18:05
Renjith Ramachandran14-May-02 18:05 
GeneralRe: Unhandled exception... Pin
SilverShalkin15-May-02 3:44
SilverShalkin15-May-02 3:44 
GeneralDrawing Image For The Web Pin
Nick Parker14-May-02 14:29
protectorNick Parker14-May-02 14:29 
GeneralSort algorithm Pin
John Cruz14-May-02 12:45
John Cruz14-May-02 12:45 
GeneralRe: Sort algorithm Pin
Christian Graus14-May-02 12:51
protectorChristian Graus14-May-02 12:51 
GeneralRe: Sort algorithm Pin
John Cruz14-May-02 13:00
John Cruz14-May-02 13:00 
GeneralRe: Sort algorithm Pin
Christian Graus14-May-02 13:02
protectorChristian Graus14-May-02 13:02 
GeneralRe: Sort algorithm Pin
John Cruz14-May-02 13:15
John Cruz14-May-02 13:15 
Christian Graus wrote:
Oh - your one include was iostream and your error was unable to find sort ? It's in algorithm.

You'll still need to move Compare so it's defined before you call it, or forward declare it.



i got both of that and i have included it like this:

#include <iostream>
#include <algorithm>

using std::sort;
using std::cout;
using std::cin;

struct SPRITE
{
int x;
int y;
};

// Maximum number of sprites
const int N_SPRITES = 10;

// Array of sprites
SPRITE sprites[N_SPRITES];

bool Compare (const SPRITE &one, const SPRITE &two)
/* Pre: Enter value for one and two
* Post: Compares all of both strings
*/
{
return (one.y < two.y);
}


int main()
{
int value;

for (int i=0; i<n_sprites; i++)
="" {
="" cout="" <<="" "enter="" a="" value:="" ";
="" cin="">> value;
sprites[i].y = value;
}

sort(sprites[0], sprites[9], Compare);

for (i=0; i
GeneralRe: Sort algorithm Pin
Christian Graus14-May-02 13:48
protectorChristian Graus14-May-02 13:48 
GeneralRe: Sort algorithm Pin
John Cruz14-May-02 14:23
John Cruz14-May-02 14:23 
GeneralRe: Sort algorithm Pin
Christian Graus14-May-02 15:02
protectorChristian Graus14-May-02 15:02 
GeneralRe: Sort algorithm Pin
John Cruz14-May-02 16:32
John Cruz14-May-02 16:32 
GeneralRe: Sort algorithm Pin
Christian Graus14-May-02 17:44
protectorChristian Graus14-May-02 17:44 
GeneralRe: Sort algorithm Pin
Jon Hulatt15-May-02 0:09
Jon Hulatt15-May-02 0:09 
Generalincreasing maximum threads per process Pin
scott sanders14-May-02 12:21
scott sanders14-May-02 12:21 
GeneralRe: increasing maximum threads per process Pin
Anders Molin14-May-02 12:38
professionalAnders Molin14-May-02 12:38 
GeneralRe: increasing maximum threads per process Pin
Tim Smith14-May-02 12:44
Tim Smith14-May-02 12:44 
GeneralRe: increasing maximum threads per process Pin
Andrew Hafen14-May-02 13:07
Andrew Hafen14-May-02 13:07 
GeneralPredefined control class names Pin
ed987114-May-02 11:30
ed987114-May-02 11:30 
GeneralRe: Predefined control class names Pin
Larry Antram14-May-02 12:00
Larry Antram14-May-02 12:00 
GeneralShowing a larger image in a small PictureBox Pin
14-May-02 11:05
suss14-May-02 11:05 
GeneralRe: Showing a larger image in a small PictureBox Pin
Jason Henderson14-May-02 11:37
Jason Henderson14-May-02 11:37 
Generalstring arrays in vc++ Pin
14-May-02 10:46
suss14-May-02 10:46 
GeneralRe: string arrays in vc++ Pin
valikac14-May-02 11:25
valikac14-May-02 11:25 
GeneralRe: string arrays in vc++ Pin
Ravi Bhavnani14-May-02 17:10
professionalRavi Bhavnani14-May-02 17:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.