Click here to Skip to main content
15,889,852 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: ?: operator Pin
Tim Smith18-Sep-05 5:37
Tim Smith18-Sep-05 5:37 
AnswerRe: ?: operator Pin
Bob Stanneveld18-Sep-05 1:57
Bob Stanneveld18-Sep-05 1:57 
GeneralRe: ?: operator Pin
Johann Gerell18-Sep-05 6:14
Johann Gerell18-Sep-05 6:14 
GeneralRe: ?: operator Pin
Bob Stanneveld18-Sep-05 7:25
Bob Stanneveld18-Sep-05 7:25 
AnswerRe: ?: operator Pin
Gary R. Wheeler18-Sep-05 3:05
Gary R. Wheeler18-Sep-05 3:05 
GeneralRe: ?: operator Pin
Maxwell Chen18-Sep-05 17:04
Maxwell Chen18-Sep-05 17:04 
GeneralRe: ?: operator Pin
ThatsAlok18-Sep-05 18:47
ThatsAlok18-Sep-05 18:47 
GeneralRe: ?: operator Pin
Maxwell Chen18-Sep-05 19:22
Maxwell Chen18-Sep-05 19:22 
About four years ago I did some test about your question with VC++6. Just now I did again with VC++7.1. My method is as:

void Test_If(bool& v1, int& v2)
{
	if(v1) {
		v2 = 0;
	}
	else {
		v2 = 1;
	}
}

void Test_Op(bool& v1, int& v2)
{
	v2 = v1 ? 0 : 1;
}

void CTestComboDlg::OnBnClickedButton1()
{
	bool v1 = true;
	int v2 = 3;
	int i;
	DWORD ds, de;

	ds = GetTickCount();
	for(i = 0; i < 0x10000000; i++) {
		Test_If(v1, v2);
	}
	de = GetTickCount();
	TRACE("IF: %u \n", de - ds);

	ds = GetTickCount();
	for(i = 0; i < 0x10000000; i++) {
		Test_Op(v1, v2);
	}
	de = GetTickCount();
	TRACE("OP: %u \n", de - ds);
}
The output is:
IF: 48690 
OP: 52576 



Maxwell Chen
GeneralRe: ?: operator Pin
ThatsAlok18-Sep-05 21:48
ThatsAlok18-Sep-05 21:48 
GeneralRe: ?: operator Pin
toxcct18-Sep-05 20:47
toxcct18-Sep-05 20:47 
GeneralRe: ?: operator Pin
Blake Miller19-Sep-05 10:47
Blake Miller19-Sep-05 10:47 
QuestionProblem with menu Shortcut keys in my VC++ dialog based Application. Pin
G Haranadh17-Sep-05 19:08
G Haranadh17-Sep-05 19:08 
AnswerRe: Problem with menu Shortcut keys in my VC++ dialog based Application. Pin
benjnp17-Sep-05 19:17
benjnp17-Sep-05 19:17 
AnswerRe: Problem with menu Shortcut keys in my VC++ dialog based Application. Pin
G Haranadh17-Sep-05 19:20
G Haranadh17-Sep-05 19:20 
AnswerRe: Problem with menu Shortcut keys in my VC++ dialog based Application. Pin
Jose Lamas Rios17-Sep-05 19:38
Jose Lamas Rios17-Sep-05 19:38 
AnswerRe: Problem with menu Shortcut keys in my VC++ dialog based Application. Pin
G Haranadh17-Sep-05 19:46
G Haranadh17-Sep-05 19:46 
GeneralRe: Problem with menu Shortcut keys in my VC++ dialog based Application. Pin
Jose Lamas Rios17-Sep-05 20:18
Jose Lamas Rios17-Sep-05 20:18 
QuestionCString question Pin
benjnp17-Sep-05 18:48
benjnp17-Sep-05 18:48 
AnswerRe: CString question Pin
Michael Dunn17-Sep-05 18:56
sitebuilderMichael Dunn17-Sep-05 18:56 
GeneralRe: CString question Pin
benjnp17-Sep-05 19:02
benjnp17-Sep-05 19:02 
AnswerRe: CString question Pin
Neelesh K J Jain17-Sep-05 19:08
Neelesh K J Jain17-Sep-05 19:08 
GeneralRe: CString question Pin
benjnp17-Sep-05 19:14
benjnp17-Sep-05 19:14 
GeneralRe: CString question Pin
Jack Puppy17-Sep-05 19:23
Jack Puppy17-Sep-05 19:23 
GeneralRe: CString question Pin
benjnp17-Sep-05 19:26
benjnp17-Sep-05 19:26 
GeneralRe: CString question Pin
Neelesh K J Jain17-Sep-05 19:25
Neelesh K J Jain17-Sep-05 19:25 

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.