Click here to Skip to main content
15,888,610 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: About database in vc++ : Plz Help : urgent Pin
Boaz V5-Oct-05 21:02
Boaz V5-Oct-05 21:02 
QuestionError encountered while displaying TIF Image with CXImage Library Pin
asifrogers5-Oct-05 19:59
asifrogers5-Oct-05 19:59 
QuestionNamespace Pin
Rajesh match5-Oct-05 19:51
Rajesh match5-Oct-05 19:51 
QuestionMultiple modeless Dialog Boxes Z-Order Pin
bgray905-Oct-05 19:41
bgray905-Oct-05 19:41 
QuestionWindows Movie Maker Timeline control Pin
Member 15698255-Oct-05 19:29
Member 15698255-Oct-05 19:29 
QuestionCBitmap on Top of other control Pin
fjlv20055-Oct-05 16:06
fjlv20055-Oct-05 16:06 
Question++Variable or Variable++ Pin
kenexcelon5-Oct-05 15:55
kenexcelon5-Oct-05 15:55 
AnswerRe: ++Variable or Variable++ Pin
Tim Smith5-Oct-05 16:12
Tim Smith5-Oct-05 16:12 
Well, one is a pre-increment and the other is a post increment. When used inside a complex statement, it does matter which one you use.

For example:

int c = *p++; // get the character and then increment the pointer

int c = *++p; // increment the pointer and then get the character

For the most part, when standing by itself, it doesn't matter which you use. However, on complex objects, pre-increment can perform a lot better than post-increment.

For example - assume we needed to implement pre and post increment for a class.

pre-increment:

value = value + 1;
return value;

post-increment:

oldvalue = value;
value = value + 1;
return oldvalue;

As you can see, to do a post-increment, you first have to make a copy of the value so it can be returned to the caller. The good news is that most optimizers will optimize it away if you aren't interested in the return value. (for example, in a "for" statement)

So which should you use? If it doesn't matter, get use to using pre-increments.

Tim Smith

I'm going to patent thought. I have yet to see any prior art.
GeneralRe: ++Variable or Variable++ Pin
Rob Caldecott5-Oct-05 22:19
Rob Caldecott5-Oct-05 22:19 
AnswerRe: ++Variable or Variable++ Pin
vikas amin5-Oct-05 23:45
vikas amin5-Oct-05 23:45 
GeneralRe: ++Variable or Variable++ Pin
Eytukan6-Oct-05 2:07
Eytukan6-Oct-05 2:07 
QuestionBitmap Transparency in EVC3.0 Pin
fjlv20055-Oct-05 15:55
fjlv20055-Oct-05 15:55 
QuestionHWND, HINSTANCE, HDC and HGLRC Pin
Alex Cutovoi5-Oct-05 15:46
Alex Cutovoi5-Oct-05 15:46 
AnswerRe: HWND, HINSTANCE, HDC and HGLRC Pin
S Douglas5-Oct-05 22:52
professionalS Douglas5-Oct-05 22:52 
GeneralRe: HWND, HINSTANCE, HDC and HGLRC Pin
Alex Cutovoi6-Oct-05 3:27
Alex Cutovoi6-Oct-05 3:27 
GeneralRe: HWND, HINSTANCE, HDC and HGLRC Pin
S Douglas6-Oct-05 3:53
professionalS Douglas6-Oct-05 3:53 
GeneralRe: HWND, HINSTANCE, HDC and HGLRC Pin
Alex Cutovoi6-Oct-05 9:43
Alex Cutovoi6-Oct-05 9:43 
GeneralRe: HWND, HINSTANCE, HDC and HGLRC Pin
S Douglas6-Oct-05 18:05
professionalS Douglas6-Oct-05 18:05 
QuestiontNewbie - Switch Statement Pin
kenexcelon5-Oct-05 15:12
kenexcelon5-Oct-05 15:12 
AnswerRe: tNewbie - Switch Statement Pin
enjoycrack5-Oct-05 15:16
enjoycrack5-Oct-05 15:16 
AnswerRe: tNewbie - Switch Statement Pin
Shog95-Oct-05 15:24
sitebuilderShog95-Oct-05 15:24 
GeneralRe: tNewbie - Switch Statement Pin
Jose Lamas Rios5-Oct-05 18:14
Jose Lamas Rios5-Oct-05 18:14 
QuestionWriting Http msgs to LOG file Pin
aman20065-Oct-05 14:20
aman20065-Oct-05 14:20 
AnswerRe: Writing Http msgs to LOG file Pin
enjoycrack5-Oct-05 15:14
enjoycrack5-Oct-05 15:14 
GeneralRe: Writing Http msgs to LOG file Pin
aman20065-Oct-05 15:58
aman20065-Oct-05 15:58 

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.