Click here to Skip to main content
15,914,016 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CMenu with Bitmap icon Pin
Drakesal2-Sep-14 20:54
Drakesal2-Sep-14 20:54 
QuestionC++ Open the COM Port on Windows CE Device Pin
baranils1-Sep-14 9:27
baranils1-Sep-14 9:27 
GeneralRe: C++ Open the COM Port on Windows CE Device Pin
CPallini1-Sep-14 9:52
mveCPallini1-Sep-14 9:52 
GeneralRe: C++ Open the COM Port on Windows CE Device Pin
baranils1-Sep-14 19:06
baranils1-Sep-14 19:06 
GeneralRe: C++ Open the COM Port on Windows CE Device Pin
CPallini1-Sep-14 19:43
mveCPallini1-Sep-14 19:43 
GeneralRe: C++ Open the COM Port on Windows CE Device Pin
Randor 2-Sep-14 12:14
professional Randor 2-Sep-14 12:14 
QuestionRe: C++ Open the COM Port on Windows CE Device Pin
CPallini2-Sep-14 20:25
mveCPallini2-Sep-14 20:25 
AnswerRe: C++ Open the COM Port on Windows CE Device Pin
leon de boer2-Sep-14 21:53
leon de boer2-Sep-14 21:53 
GeneralRe: C++ Open the COM Port on Windows CE Device Pin
CPallini2-Sep-14 21:59
mveCPallini2-Sep-14 21:59 
QuestionHow to fix the first column of a CListView in MFC Pin
sma123#31-Aug-14 23:57
sma123#31-Aug-14 23:57 
AnswerRe: How to fix the first column of a CListView in MFC Pin
David Crow2-Sep-14 3:50
David Crow2-Sep-14 3:50 
QuestionAnother academic question - ANSI C standard on optional function parameters Pin
Vaclav_31-Aug-14 8:01
Vaclav_31-Aug-14 8:01 
AnswerRe: Another academic question - ANSI C standard on optional function parameters Pin
Richard MacCutchan31-Aug-14 20:47
mveRichard MacCutchan31-Aug-14 20:47 
AnswerRe: Another academic question - ANSI C standard on optional function parameters Pin
CPallini1-Sep-14 4:24
mveCPallini1-Sep-14 4:24 
GeneralRe: Another academic question - ANSI C standard on optional function parameters Pin
Vaclav_1-Sep-14 5:33
Vaclav_1-Sep-14 5:33 
GeneralRe: Another academic question - ANSI C standard on optional function parameters Pin
Richard MacCutchan1-Sep-14 6:52
mveRichard MacCutchan1-Sep-14 6:52 
GeneralRe: Another academic question - ANSI C standard on optional function parameters Pin
Vaclav_1-Sep-14 7:55
Vaclav_1-Sep-14 7:55 
GeneralRe: Another academic question - ANSI C standard on optional function parameters Pin
CPallini1-Sep-14 9:39
mveCPallini1-Sep-14 9:39 
GeneralRe: Another academic question - ANSI C standard on optional function parameters Pin
Richard MacCutchan1-Sep-14 21:23
mveRichard MacCutchan1-Sep-14 21:23 
GeneralRe: Another academic question - ANSI C standard on optional function parameters Pin
Vaclav_2-Sep-14 8:11
Vaclav_2-Sep-14 8:11 
GeneralRe: Another academic question - ANSI C standard on optional function parameters Pin
Richard MacCutchan2-Sep-14 20:31
mveRichard MacCutchan2-Sep-14 20:31 
GeneralRe: Another academic question - ANSI C standard on optional function parameters Pin
Vaclav_6-Sep-14 5:59
Vaclav_6-Sep-14 5:59 
GeneralRe: Another academic question - ANSI C standard on optional function parameters Pin
Richard MacCutchan6-Sep-14 6:10
mveRichard MacCutchan6-Sep-14 6:10 
GeneralRe: Another academic question - ANSI C standard on optional function parameters Pin
Stefan_Lang2-Sep-14 21:11
Stefan_Lang2-Sep-14 21:11 
AnswerRe: Another academic question - ANSI C standard on optional function parameters Pin
Stefan_Lang2-Sep-14 0:52
Stefan_Lang2-Sep-14 0:52 
Since C doesn't allow overloading to start with, the only way to call a function with alternate sets of parameters is by thinking up a pattern on how you pass these parameters in a less rigid way.

One way has already been mentioned: passing an array of void pointers. The disadvantage is that you have to figure out what is what, including type, and if more than one parameter is optional you need to additionally pass some information about which of the parameters were skipped.

Pretty much the same goes for vararg lists.

A slightly better approach that offers strict control over types and meaning of parameters is passing a struct that contains all possible parameters: write one function that allocates and/or initializes the struct with defaults, and in the code overwrite all values that you want different, then pass the struct to your processing function. If you have mandatory parameters without sensible defaults (e. g. array sizes), make sure to pass these to the intialization function.
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)

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.