Click here to Skip to main content
15,919,931 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Exporting data to mutiple.txt files Pin
led mike14-Jun-07 10:44
led mike14-Jun-07 10:44 
QuestionForced scoping as a programming technique? Pin
Cyrilix14-Jun-07 5:53
Cyrilix14-Jun-07 5:53 
AnswerRe: Forced scoping as a programming technique? Pin
Michael Dunn14-Jun-07 6:27
sitebuilderMichael Dunn14-Jun-07 6:27 
GeneralRe: Forced scoping as a programming technique? Pin
Nemanja Trifunovic14-Jun-07 6:28
Nemanja Trifunovic14-Jun-07 6:28 
GeneralRe: Forced scoping as a programming technique? Pin
Cyrilix14-Jun-07 6:43
Cyrilix14-Jun-07 6:43 
GeneralRe: Forced scoping as a programming technique? Pin
jbarton14-Jun-07 8:53
jbarton14-Jun-07 8:53 
GeneralRe: Forced scoping as a programming technique? Pin
Cyrilix14-Jun-07 9:38
Cyrilix14-Jun-07 9:38 
GeneralRe: Forced scoping as a programming technique? Pin
jbarton14-Jun-07 9:57
jbarton14-Jun-07 9:57 
The main point I was trying to get across was that you should avoid using macros in C++ except in a very small number of special cases. Using macros is generally the C method of doing things, not the C++ method.

Whether you make the routine that replaces the macro into an inline routine or just a callable routine is not important. I only suggested an inline routine since it produces almost exactly the same result as a macro - no additional function call being made in the generated code. You would get the same benefits with a normal routine instead of an inline routine except the generated code would probably include a call to this normal routine. Note: some compilers may choose to inline a small normal routine without you adding the inline keyword. Also, some routines marked as inline might still result in a function call - the compiler doesn't have to inline a routine when you tell it to inline. This generally doesn't happen, but there are a few cases where it is needed (such as if you get a pointer to the inline routine and then call it through the pointer).

The usage of smart pointers may or may not be appropriate in your case. It just tends to make the cleanup code a lot easier. As long as you can arrange to have the scope of the variable end when you no longer need the resource, then you don't need to do any explicit calls to delete the object. Sometimes it just takes a little reorganization to take advantage of smart pointers. Without seeing your code, I can't tell whether you could use smart pointers by just rearranging things a bit.

You said that you were placing the pointers into an STL collection for future cleanup. You could place a boost::shared_ptr into the collection, which would simplify the eventual cleanup. Instead of needing to loop through the collection and manually deleting each pointer, you can just clear the collection. The boost::shared_ptr would then take care of cleanup automatically.

GeneralRe: Forced scoping as a programming technique? Pin
Cyrilix14-Jun-07 10:38
Cyrilix14-Jun-07 10:38 
GeneralRe: Forced scoping as a programming technique? Pin
jbarton15-Jun-07 3:20
jbarton15-Jun-07 3:20 
GeneralRe: Forced scoping as a programming technique? [modified] Pin
Cyrilix15-Jun-07 3:45
Cyrilix15-Jun-07 3:45 
AnswerRe: Forced scoping as a programming technique? Pin
Nemanja Trifunovic14-Jun-07 6:27
Nemanja Trifunovic14-Jun-07 6:27 
AnswerRe: Forced scoping as a programming technique? Pin
bob1697214-Jun-07 8:12
bob1697214-Jun-07 8:12 
Questionsetting executable icon Pin
R Thompson14-Jun-07 5:44
R Thompson14-Jun-07 5:44 
AnswerRe: setting executable icon Pin
R Thompson14-Jun-07 6:11
R Thompson14-Jun-07 6:11 
AnswerRe: setting executable icon Pin
Michael Dunn14-Jun-07 6:28
sitebuilderMichael Dunn14-Jun-07 6:28 
QuestionRe: setting executable icon Pin
Hamid_RT14-Jun-07 19:44
Hamid_RT14-Jun-07 19:44 
QuestionSave Screenshot Pin
CDRAIN14-Jun-07 4:54
CDRAIN14-Jun-07 4:54 
QuestionRe: Save Screenshot Pin
David Crow14-Jun-07 5:40
David Crow14-Jun-07 5:40 
AnswerRe: Save Screenshot Pin
Naveen14-Jun-07 14:30
Naveen14-Jun-07 14:30 
QuestionRe: Save Screenshot Pin
Hamid_RT14-Jun-07 19:41
Hamid_RT14-Jun-07 19:41 
AnswerRe: Save Screenshot [modified] Pin
CDRAIN15-Jun-07 0:46
CDRAIN15-Jun-07 0:46 
GeneralRe: Save Screenshot Pin
Hamid_RT15-Jun-07 2:56
Hamid_RT15-Jun-07 2:56 
GeneralRe: Save Screenshot Pin
CDRAIN15-Jun-07 3:28
CDRAIN15-Jun-07 3:28 
GeneralRe: Save Screenshot Pin
Hamid_RT15-Jun-07 5:29
Hamid_RT15-Jun-07 5:29 

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.