Click here to Skip to main content
16,011,170 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: application wide global variables Pin
antlers15-Sep-03 5:23
antlers15-Sep-03 5:23 
GeneralRe: application wide global variables Pin
Johnny ²15-Sep-03 5:35
Johnny ²15-Sep-03 5:35 
GeneralRe: application wide global variables Pin
Alvaro Mendez15-Sep-03 6:25
Alvaro Mendez15-Sep-03 6:25 
GeneralRe: application wide global variables Pin
Johnny ²15-Sep-03 7:55
Johnny ²15-Sep-03 7:55 
GeneralRe: application wide global variables Pin
Alvaro Mendez15-Sep-03 12:11
Alvaro Mendez15-Sep-03 12:11 
GeneralRe: application wide global variables Pin
Alvaro Mendez15-Sep-03 6:29
Alvaro Mendez15-Sep-03 6:29 
GeneralRe: application wide global variables Pin
r i s h a b h s15-Sep-03 18:24
r i s h a b h s15-Sep-03 18:24 
GeneralRe: application wide global variables Pin
antlers16-Sep-03 5:34
antlers16-Sep-03 5:34 
When you declare something you tell the compiler that a symbol of that name and type will be available at link time.

When you define something, you tell the compiler not only that the variable or function exists, but that it must reserve space for that variable, or create object code for that function, in the current translation unit (.cpp file). When you declare a function or method, you don't include the function body.

You generally put your declarations in header files, which can be shared by many .cpp files that might be part of your program.

You put your definitions in a .cpp file. Generally, each .cpp file together with all the headers it includes make a single translation unit that the compiler converts to a single object file. The object file contains object code for functions defined within the translation unit, and reserves space for static or global variables defined within the translation unit, but it contains only references to functions or variables that were declared but not defined. The linker resolves the references to declared symbols to when it links the object files together with any required libraries to make your final executable.

So in compiling all the parts of your program, the compiler will see the declaration of a symbol several times (once per translation unit that sees the symbol declared) but the definition only once (in the translation unit where the symbol is defined).
GeneralRe: application wide global variables Pin
Michael Dunn15-Sep-03 5:47
sitebuilderMichael Dunn15-Sep-03 5:47 
GeneralRe: application wide global variables Pin
Navin15-Sep-03 6:54
Navin15-Sep-03 6:54 
GeneralNTFS Driver information Pin
abhinarulkar15-Sep-03 3:02
abhinarulkar15-Sep-03 3:02 
GeneralRe: NTFS Driver information Pin
Alexander M.,16-Sep-03 5:18
Alexander M.,16-Sep-03 5:18 
GeneralException about "Float Invalid Opration" Pin
yzpower15-Sep-03 2:33
sussyzpower15-Sep-03 2:33 
GeneralRe: Exception about "Float Invalid Opration" Pin
Jagadeesh VN15-Sep-03 3:13
Jagadeesh VN15-Sep-03 3:13 
GeneralPlease help me! Thanks! Pin
HansonDavid15-Sep-03 2:24
HansonDavid15-Sep-03 2:24 
GeneralMultiples views in Doc/View Pin
Cedric Moonen15-Sep-03 2:03
Cedric Moonen15-Sep-03 2:03 
GeneralRe: Multiples views in Doc/View Pin
JWood15-Sep-03 3:40
JWood15-Sep-03 3:40 
GeneralRe: Multiples views in Doc/View Pin
Cedric Moonen15-Sep-03 4:06
Cedric Moonen15-Sep-03 4:06 
GeneralRe: Multiples views in Doc/View Pin
JWood15-Sep-03 4:15
JWood15-Sep-03 4:15 
GeneralRe: Multiples views in Doc/View Pin
Cedric Moonen15-Sep-03 4:34
Cedric Moonen15-Sep-03 4:34 
GeneralRe: Multiples views in Doc/View Pin
JWood15-Sep-03 4:51
JWood15-Sep-03 4:51 
GeneralRe: Multiples views in Doc/View Pin
Cedric Moonen15-Sep-03 5:15
Cedric Moonen15-Sep-03 5:15 
GeneralRe: Multiples views in Doc/View Pin
JWood15-Sep-03 5:54
JWood15-Sep-03 5:54 
GeneralRe: Multiples views in Doc/View Pin
Cedric Moonen15-Sep-03 21:46
Cedric Moonen15-Sep-03 21:46 
Questionopen IE??? Pin
xxhimanshu15-Sep-03 1:59
xxhimanshu15-Sep-03 1:59 

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.