Click here to Skip to main content
15,908,906 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionSTL sort throw exception? Pin
George_George4-Jan-08 4:06
George_George4-Jan-08 4:06 
AnswerRe: STL sort throw exception? [modified] Pin
Maxwell Chen4-Jan-08 6:42
Maxwell Chen4-Jan-08 6:42 
GeneralRe: STL sort throw exception? Pin
George_George4-Jan-08 21:59
George_George4-Jan-08 21:59 
AnswerRe: STL sort throw exception? Pin
Nemanja Trifunovic4-Jan-08 7:34
Nemanja Trifunovic4-Jan-08 7:34 
GeneralRe: STL sort throw exception? Pin
George_George4-Jan-08 21:53
George_George4-Jan-08 21:53 
AnswerRe: STL sort throw exception? Pin
Eytukan4-Jan-08 22:37
Eytukan4-Jan-08 22:37 
GeneralRe: STL sort throw exception? Pin
George_George4-Jan-08 23:03
George_George4-Jan-08 23:03 
GeneralRe: STL sort throw exception? Pin
Eytukan5-Jan-08 1:46
Eytukan5-Jan-08 1:46 
Ahh boy! Listen the first question that should have arised and get solved immediately is that "How should a sort would fail?".. the next is that "The sort is designed to sort things and not to fail,so it WILL NOT FAIL".

If you look at the document, it says "USER DEFINDED SORTS", ok I make an example of what they are talking about. Just try to execute the below sample in your machine twice. The next time you run it, remove the i=i/0 line from the code.
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;

class test
{
private:

	

public:
	int nValue;
	bool operator <(test obj)
	{
		int i= i/0;
		if(this->nValue<obj.nValue)
		{
			return(true);
		}
		else
		{
			return(false);
		}
	}
	

};

int main(int argc, char* argv[])
{
	printf("Hello World!\n");
	std::vector<test> vec_testObj;
	test testObjs[4];
	testObjs[0].nValue =5;
	testObjs[1].nValue =4;
	testObjs[2].nValue =3;
	testObjs[3].nValue =2;
	vec_testObj.push_back(testObjs[0]);
	vec_testObj.push_back(testObjs[1]);
	vec_testObj.push_back(testObjs[2]);
	vec_testObj.push_back(testObjs[3]);
	std::sort(vec_testObj.begin(),vec_testObj.end());
	vector<test>::iterator itr_vecTest = vec_testObj.begin();
	while(vec_testObj.end()!=itr_vecTest)
	{
		cout<<"\n"<<itr_vecTest->nValue;
		itr_vecTest++;
	}
	
	return 0;
}






OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus


Best wishes to Rexx[^]

GeneralRe: STL sort throw exception? Pin
George_George5-Jan-08 2:37
George_George5-Jan-08 2:37 
GeneralRe: STL sort throw exception? Pin
Eytukan5-Jan-08 2:44
Eytukan5-Jan-08 2:44 
GeneralRe: STL sort throw exception? Pin
George_George5-Jan-08 3:02
George_George5-Jan-08 3:02 
QuestionMFC and Unicode Pin
mtzlplyk4-Jan-08 3:40
mtzlplyk4-Jan-08 3:40 
GeneralRe: MFC and Unicode Pin
Matthew Faithfull4-Jan-08 4:05
Matthew Faithfull4-Jan-08 4:05 
GeneralRe: MFC and Unicode Pin
mtzlplyk4-Jan-08 4:36
mtzlplyk4-Jan-08 4:36 
QuestionRe: MFC and Unicode Pin
Matthew Faithfull4-Jan-08 5:51
Matthew Faithfull4-Jan-08 5:51 
GeneralRe: MFC and Unicode Pin
mtzlplyk4-Jan-08 9:13
mtzlplyk4-Jan-08 9:13 
GeneralChange in rich edit control behaviour with EM_EXSETSEL / SetSel Pin
Paul Vickery4-Jan-08 3:04
professionalPaul Vickery4-Jan-08 3:04 
GeneralRe: Change in rich edit control behaviour with EM_EXSETSEL / SetSel Pin
Vaclav_4-Jan-08 4:14
Vaclav_4-Jan-08 4:14 
GeneralRe: Change in rich edit control behaviour with EM_EXSETSEL / SetSel Pin
Paul Vickery8-Jan-08 0:00
professionalPaul Vickery8-Jan-08 0:00 
GeneralRe: Change in rich edit control behaviour with EM_EXSETSEL / SetSel Pin
Vaclav_8-Jan-08 6:55
Vaclav_8-Jan-08 6:55 
QuestionRe: Change in rich edit control behaviour with EM_EXSETSEL / SetSel Pin
Mark Salsbery4-Jan-08 6:56
Mark Salsbery4-Jan-08 6:56 
GeneralRe: Change in rich edit control behaviour with EM_EXSETSEL / SetSel Pin
Paul Vickery9-Jan-08 4:49
professionalPaul Vickery9-Jan-08 4:49 
GeneralSaving settings \ Remembering settings after reboot Pin
thes3cr3t14-Jan-08 2:32
thes3cr3t14-Jan-08 2:32 
GeneralRe: Saving settings \ Remembering settings after reboot Pin
CPallini4-Jan-08 2:45
mveCPallini4-Jan-08 2:45 
GeneralRe: Saving settings \ Remembering settings after reboot Pin
Rajesh R Subramanian4-Jan-08 5:36
professionalRajesh R Subramanian4-Jan-08 5:36 

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.