Click here to Skip to main content
15,895,084 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Multithreading question Pin
Munchies_Matt23-Jan-17 6:32
Munchies_Matt23-Jan-17 6:32 
QuestionMFC ribbon designer (gallery button) Pin
Maximilien6-Jan-17 9:43
Maximilien6-Jan-17 9:43 
AnswerRe: MFC ribbon designer (gallery button) Pin
DeeEllEll30-Mar-17 4:55
DeeEllEll30-Mar-17 4:55 
QuestionIs function prototyping dead? Pin
Vaclav_6-Jan-17 5:43
Vaclav_6-Jan-17 5:43 
AnswerRe: Is function prototyping dead? Pin
Richard MacCutchan6-Jan-17 5:49
mveRichard MacCutchan6-Jan-17 5:49 
GeneralRe: Is function prototyping dead? Pin
Vaclav_6-Jan-17 16:19
Vaclav_6-Jan-17 16:19 
GeneralRe: Is function prototyping dead? Pin
Richard MacCutchan6-Jan-17 21:55
mveRichard MacCutchan6-Jan-17 21:55 
AnswerRe: Is function prototyping dead? Pin
Jochen Arndt6-Jan-17 22:17
professionalJochen Arndt6-Jan-17 22:17 
A declaration (prototype) describes an object (function, class, variable).
C++
int some_function(int some_arg);

A definition (implementation) implements an object.
C++
int some_function(int some_arg)
{
    int result = 0;
    // some code
    return result;
}

If there is no declaration for an object, the definition implies the declaration.

The compiler needs a declaration when an object is used the first time (accessing a variable, calling a function). So there is no need for a declaration if the first usage is located after the definition in the source code.

While strictly speaking all declarations are forward declarations, the term is mainly used with function declarations in header files where a pointer or reference to another class is passed as function argument. An example:
C++
// Header file for MyClass

// Forward declaration for OtherClass.
class OtherClass;

class MyClass
{
    MyClass();
    SomeFunction(OtherClass &otherClass);
};
The implementation file of MyClass must still include the header file containing the OtherClass declaration. But the above header file must not do so which reduces the compile time. More important, this must be used when both classes use the other which would normally require that both header files include each other which would lock the compiler (recursive inclusion).

See also this SO thread: c++ - What is the difference between a definition and a declaration? - Stack Overflow[^]
GeneralRe: Is function prototyping dead? Pin
Vaclav_7-Jan-17 4:29
Vaclav_7-Jan-17 4:29 
GeneralRe: Is function prototyping dead? Pin
Jochen Arndt8-Jan-17 20:58
professionalJochen Arndt8-Jan-17 20:58 
AnswerRe: Is function prototyping dead? Pin
Jochen Arndt6-Jan-17 6:49
professionalJochen Arndt6-Jan-17 6:49 
QuestionMulti Core question Pin
ForNow4-Jan-17 4:11
ForNow4-Jan-17 4:11 
AnswerRe: Multi Core question Pin
Jochen Arndt4-Jan-17 4:39
professionalJochen Arndt4-Jan-17 4:39 
GeneralRe: Multi Core question Pin
ForNow4-Jan-17 4:50
ForNow4-Jan-17 4:50 
GeneralRe: Multi Core question Pin
Jochen Arndt4-Jan-17 5:01
professionalJochen Arndt4-Jan-17 5:01 
GeneralRe: Multi Core question Pin
ForNow4-Jan-17 5:06
ForNow4-Jan-17 5:06 
GeneralCreate a program Pin
Yudha Eka Saputra3-Jan-17 18:01
Yudha Eka Saputra3-Jan-17 18:01 
GeneralRe: Create a program Pin
Victor Nijegorodov3-Jan-17 22:04
Victor Nijegorodov3-Jan-17 22:04 
GeneralRe: Create a program Pin
Richard MacCutchan3-Jan-17 23:26
mveRichard MacCutchan3-Jan-17 23:26 
QuestionRe: Create a program Pin
David Crow4-Jan-17 2:57
David Crow4-Jan-17 2:57 
GeneralRe: Create a program Pin
NotPolitcallyCorrect4-Jan-17 5:08
NotPolitcallyCorrect4-Jan-17 5:08 
QuestionMigrating from Visual Studio 2005 to Visual Studio 2015 Still Tries to Link MFC 8 Pin
SP Chapman30-Dec-16 6:20
SP Chapman30-Dec-16 6:20 
AnswerRe: Migrating from Visual Studio 2005 to Visual Studio 2015 Still Tries to Link MFC 8 Pin
Richard MacCutchan30-Dec-16 20:59
mveRichard MacCutchan30-Dec-16 20:59 
AnswerRe: Migrating from Visual Studio 2005 to Visual Studio 2015 Still Tries to Link MFC 8 Pin
leon de boer31-Dec-16 3:04
leon de boer31-Dec-16 3:04 
GeneralRe: Migrating from Visual Studio 2005 to Visual Studio 2015 Still Tries to Link MFC 8 Pin
SP Chapman3-Jan-17 6:06
SP Chapman3-Jan-17 6:06 

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.