Click here to Skip to main content
15,896,269 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Launching 3rd party application from MFC Button Pin
Cool Ju1-Mar-06 22:22
Cool Ju1-Mar-06 22:22 
QuestionCalling Crystal Reports 11 from VC++ Pin
xdeveloper_del1-Mar-06 21:42
xdeveloper_del1-Mar-06 21:42 
Questionserial port sniffer Pin
szilics1-Mar-06 20:37
szilics1-Mar-06 20:37 
AnswerRe: serial port sniffer Pin
Cedric Moonen1-Mar-06 20:48
Cedric Moonen1-Mar-06 20:48 
GeneralRe: serial port sniffer Pin
szilics1-Mar-06 21:34
szilics1-Mar-06 21:34 
GeneralRe: serial port sniffer Pin
James Brown1-Mar-06 22:29
James Brown1-Mar-06 22:29 
GeneralRe: serial port sniffer Pin
szilics1-Mar-06 23:22
szilics1-Mar-06 23:22 
AnswerRe: serial port sniffer Pin
Rick York1-Mar-06 21:32
mveRick York1-Mar-06 21:32 
QuestionMultithreading Pin
Waldermort1-Mar-06 20:34
Waldermort1-Mar-06 20:34 
AnswerRe: Multithreading Pin
Naveen1-Mar-06 20:46
Naveen1-Mar-06 20:46 
GeneralRe: Multithreading Pin
Stephen Hewitt1-Mar-06 22:23
Stephen Hewitt1-Mar-06 22:23 
GeneralRe: Multithreading Pin
Naveen1-Mar-06 23:28
Naveen1-Mar-06 23:28 
AnswerRe: Multithreading Pin
Cedric Moonen1-Mar-06 21:00
Cedric Moonen1-Mar-06 21:00 
GeneralRe: Multithreading Pin
Waldermort1-Mar-06 21:54
Waldermort1-Mar-06 21:54 
GeneralRe: Multithreading Pin
Cedric Moonen1-Mar-06 22:19
Cedric Moonen1-Mar-06 22:19 
AnswerRe: Multithreading Pin
Joe Woodbury1-Mar-06 21:20
professionalJoe Woodbury1-Mar-06 21:20 
Questionc++ Pin
yaaqub1-Mar-06 20:28
yaaqub1-Mar-06 20:28 
AnswerRe: c++ Pin
Nibu babu thomas1-Mar-06 20:33
Nibu babu thomas1-Mar-06 20:33 
AnswerRe: c++ Pin
Stephen Hewitt1-Mar-06 22:28
Stephen Hewitt1-Mar-06 22:28 
Here is an example of how to use std::sort:
-------------------------------------------

#include <iostream>
#include <algorithm>
#include <iterator>
using namespace std;

// Our data.
struct Blah
{
Blah(int Type, const char* pName) :
m_Type(Type), m_pName(pName)
{
}

int m_Type;
const char* m_pName;
};

// Print out a blah.
ostream& operator<<(ostream& s, const Blah& b)
{
s << "Type: " << b.m_Type << ", Name: \"" << b.m_pName << "\"";
return s;
}

// Sort functors.
struct SortByType
{
bool operator()(const Blah& l, const Blah& r) const
{
return l.m_Type < r.m_Type;
}
};

struct SortByName
{
bool operator()(const Blah& l, const Blah& r) const
{
return strcmp(l.m_pName, r.m_pName) < 0;
}
};

struct SortByTypeThenName
{
bool operator()(const Blah& l, const Blah& r) const
{
return SortByType()(l, r) | (!SortByType()(r, l) && SortByName()(l, r));
}
};

// The data.
Blah g_Blahs[] =
{
Blah(1, "George"), Blah(2, "Liam"), Blah(2, "Hank"),
Blah(0, "Abigail"), Blah(1, "Bob"), Blah(0, "Jessica"),
Blah(2, "Con"), Blah(1, "Kyle"), Blah(0, "Faye")
};

int main(int argc, char* argv[])
{
Blah* pBegin = &g_Blahs[0];
Blah* pEnd = &g_Blahs[sizeof(g_Blahs)/sizeof(g_Blahs[0])];
ostream_iterator<Blah> oi(cout, "\n");

// Sort by type.
cout << "Type:\n";
sort(pBegin, pEnd, SortByType());
copy(pBegin, pEnd, oi);
cout << "\n";

// Sort by name.
cout << "Name:\n";
sort(pBegin, pEnd, SortByName());
copy(pBegin, pEnd, oi);
cout << "\n";

// Sort by type and name.
cout << "Type and name:\n";
sort(pBegin, pEnd, SortByTypeThenName());
copy(pBegin, pEnd, oi);
cout << "\n";

return 0;
}


Steve
QuestionCombo box height is not increasing Pin
BiswaR1-Mar-06 19:45
BiswaR1-Mar-06 19:45 
AnswerRe: Combo box height is not increasing Pin
Naveen1-Mar-06 20:42
Naveen1-Mar-06 20:42 
QuestionUsing Serial Port communication for dialog based application Pin
BeakX1-Mar-06 19:44
BeakX1-Mar-06 19:44 
AnswerRe: Using Serial Port communication for dialog based application Pin
Cedric Moonen1-Mar-06 20:26
Cedric Moonen1-Mar-06 20:26 
GeneralRe: Using Serial Port communication for dialog based application Pin
Rick York1-Mar-06 21:50
mveRick York1-Mar-06 21:50 
GeneralRe: Using Serial Port communication for dialog based application Pin
Cedric Moonen1-Mar-06 22:00
Cedric Moonen1-Mar-06 22:00 

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.