Click here to Skip to main content
15,885,366 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Cannot initialize array of classes except as a local variable. Pin
David Crow24-Oct-14 10:50
David Crow24-Oct-14 10:50 
AnswerRe: Cannot initialize array of classes except as a local variable. Pin
Vaclav_24-Oct-14 15:04
Vaclav_24-Oct-14 15:04 
AnswerRe: Cannot initialize array of classes except as a local variable. Pin
Stefan_Lang27-Oct-14 4:02
Stefan_Lang27-Oct-14 4:02 
QuestionRecursive function - how to correctly implement return? Pin
Vaclav_22-Oct-14 9:20
Vaclav_22-Oct-14 9:20 
AnswerRe: Recursive function - how to correctly implement return? Pin
Richard Andrew x6422-Oct-14 10:06
professionalRichard Andrew x6422-Oct-14 10:06 
SuggestionRe: Recursive function - how to correctly implement return? Pin
«_Superman_»22-Oct-14 18:56
professional«_Superman_»22-Oct-14 18:56 
GeneralRe: Recursive function - how to correctly implement return? Pin
Vaclav_23-Oct-14 5:57
Vaclav_23-Oct-14 5:57 
AnswerRe: Recursive function - how to correctly implement return? Pin
Stefan_Lang23-Oct-14 1:57
Stefan_Lang23-Oct-14 1:57 
1. It is always possible to make do with a single return. I'm not sure what makes you think otherwise.

2. searching an array for a matching value is a trivial operation - why did you implement it recursively? What is so difficult in your search algorithm that it prevents you from implementing it in a simple loop?

3. having a static counter for depth of recursion is a common method, and it helps catching endless recursions. But, generally speaking, static variables can cause many issues - if there is even a remote chance you're going to use multithreading sometime in the future, just forget about it! Either way, a safer method is to create a context and pass a reference (i. e. pointer in C/C++) to the recursive function. That context object may contain a counter or any other mechanism to control recursion depth, but it won't be static: it lives in the context of the thread that initialiy called the recursive function, and it won't cause conflicts when that function is called from different clients at the same time.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

GeneralRe: Recursive function - how to correctly implement return? Pin
Vaclav_23-Oct-14 5:53
Vaclav_23-Oct-14 5:53 
SuggestionRe: Recursive function - how to correctly implement return? Pin
David Crow23-Oct-14 9:23
David Crow23-Oct-14 9:23 
AnswerRe: Recursive function - how to correctly implement return? Pin
CPallini23-Oct-14 23:35
mveCPallini23-Oct-14 23:35 
QuestionOccluded Objects Pin
HAMUDA7822-Oct-14 2:31
HAMUDA7822-Oct-14 2:31 
QuestionRe: Occluded Objects Pin
David Crow22-Oct-14 6:17
David Crow22-Oct-14 6:17 
SuggestionRe: Occluded Objects Pin
Stefan_Lang23-Oct-14 2:08
Stefan_Lang23-Oct-14 2:08 
AnswerRe: Occluded Objects Pin
CPallini24-Oct-14 2:41
mveCPallini24-Oct-14 2:41 
QuestionTask Manager Application List With its Name Pin
ArunPrasadS20-Oct-14 4:15
ArunPrasadS20-Oct-14 4:15 
AnswerRe: Task Manager Application List With its Name Pin
jeron120-Oct-14 4:36
jeron120-Oct-14 4:36 
QuestionMissing DirectShow BaseClasses in Windows8.1 sdk Kit Pin
002comp19-Oct-14 18:36
002comp19-Oct-14 18:36 
AnswerRe: Missing DirectShow BaseClasses in Windows8.1 sdk Kit Pin
Member 113702424-Oct-14 19:21
Member 113702424-Oct-14 19:21 
QuestionShellExecute and focus lose Pin
sdancer7519-Oct-14 0:41
sdancer7519-Oct-14 0:41 
AnswerRe: ShellExecute and focus lose Pin
Richard Andrew x6420-Oct-14 9:42
professionalRichard Andrew x6420-Oct-14 9:42 
GeneralRe: ShellExecute and focus lose Pin
sdancer7520-Oct-14 20:31
sdancer7520-Oct-14 20:31 
QuestionRe: ShellExecute and focus lose Pin
David Crow21-Oct-14 3:27
David Crow21-Oct-14 3:27 
AnswerRe: ShellExecute and focus lose Pin
sdancer7521-Oct-14 22:52
sdancer7521-Oct-14 22:52 
QuestionRe: ShellExecute and focus lose Pin
David Crow22-Oct-14 2:15
David Crow22-Oct-14 2:15 

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.