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

C / C++ / MFC

 
AnswerRe: The C++ function to create an instance given a class name. Pin
Chris Losinger21-Sep-05 6:18
professionalChris Losinger21-Sep-05 6:18 
AnswerRe: The C++ function to create an instance given a class name. Pin
Shog921-Sep-05 6:21
sitebuilderShog921-Sep-05 6:21 
QuestionStandard for inlining code Pin
Rob Caldecott21-Sep-05 4:47
Rob Caldecott21-Sep-05 4:47 
AnswerRe: Standard for inlining code Pin
Cedric Moonen21-Sep-05 4:54
Cedric Moonen21-Sep-05 4:54 
GeneralRe: Standard for inlining code Pin
Rob Caldecott21-Sep-05 4:59
Rob Caldecott21-Sep-05 4:59 
AnswerRe: Standard for inlining code Pin
Blake Miller21-Sep-05 5:09
Blake Miller21-Sep-05 5:09 
AnswerRe: Standard for inlining code Pin
Nemanja Trifunovic21-Sep-05 5:15
Nemanja Trifunovic21-Sep-05 5:15 
AnswerRe: Standard for inlining code Pin
Roger Stoltz21-Sep-05 5:56
Roger Stoltz21-Sep-05 5:56 
I've never heard or read about a MSFT policy regarding how inline member functions should be declared, but I suspect that it's due to readability reasons. Like Nemanja said "separating the interface from the implementation" in order not to clutter the interface and make it hard to read.

Regarding the syntax of the language there is nothing wrong with defining the member function in the class definition. It would make the function inline implicitly as Blake said.

In order for clients to use the inline function, the definition has to be included to make it possible for the compiler to extract the body in place. The most straight forward way to accomplish this is by have the definition in the header file. As I understand it the compiler does the same thing regardless of whether the function was defined inside the class definition or not.

Sometimes in MFC code, e.g. CDocument::GetDocument, the debug version of the function is not inline in order to step into the function. Otherwise one has to step through the assembler code to know what happens.
To write the preprocessor directive (#ifdef _DEBUG) inside the class definition wouldn't be a very beautiful code to look at for my eyes. Dead | X|
But that's a matter of taste and the compiler doesn't seems to have any.Laugh | :laugh:

--
Roger

AnswerRe: Standard for inlining code Pin
David Crow21-Sep-05 7:04
David Crow21-Sep-05 7:04 
GeneralRe: Standard for inlining code Pin
Rob Caldecott21-Sep-05 7:05
Rob Caldecott21-Sep-05 7:05 
GeneralRe: Standard for inlining code Pin
David Crow21-Sep-05 7:18
David Crow21-Sep-05 7:18 
GeneralRe: Standard for inlining code Pin
Nemanja Trifunovic21-Sep-05 7:40
Nemanja Trifunovic21-Sep-05 7:40 
GeneralRe: Standard for inlining code Pin
David Crow22-Sep-05 2:20
David Crow22-Sep-05 2:20 
AnswerRe: Standard for inlining code Pin
User 58385221-Sep-05 20:37
User 58385221-Sep-05 20:37 
GeneralRe: Standard for inlining code Pin
John R. Shaw21-Sep-05 21:01
John R. Shaw21-Sep-05 21:01 
GeneralRe: Standard for inlining code Pin
David Crow22-Sep-05 2:23
David Crow22-Sep-05 2:23 
AnswerRe: Standard for inlining code Pin
John R. Shaw21-Sep-05 21:20
John R. Shaw21-Sep-05 21:20 
QuestionInterfacing Pin
benjnp21-Sep-05 4:42
benjnp21-Sep-05 4:42 
AnswerRe: Interfacing Pin
Bob Stanneveld21-Sep-05 5:30
Bob Stanneveld21-Sep-05 5:30 
GeneralRe: Interfacing Pin
benjnp21-Sep-05 14:45
benjnp21-Sep-05 14:45 
GeneralRe: Interfacing Pin
Bob Stanneveld21-Sep-05 20:14
Bob Stanneveld21-Sep-05 20:14 
QuestionWindows Procedure Pin
benjnp21-Sep-05 4:36
benjnp21-Sep-05 4:36 
AnswerRe: Windows Procedure Pin
Blake Miller21-Sep-05 5:05
Blake Miller21-Sep-05 5:05 
AnswerRe: Windows Procedure Pin
Bob Stanneveld21-Sep-05 5:34
Bob Stanneveld21-Sep-05 5:34 
QuestionWhy does a non-blocking socket get blocked when call connect? Pin
alvaro21-Sep-05 4:32
alvaro21-Sep-05 4:32 

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.