Click here to Skip to main content
15,920,632 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: declaring a global variable [modified] Pin
Tara1426-Jun-06 9:06
Tara1426-Jun-06 9:06 
QuestionRe: declaring a global variable Pin
David Crow26-Jun-06 9:09
David Crow26-Jun-06 9:09 
AnswerRe: declaring a global variable Pin
Tara1426-Jun-06 9:15
Tara1426-Jun-06 9:15 
GeneralRe: declaring a global variable Pin
David Crow26-Jun-06 9:20
David Crow26-Jun-06 9:20 
GeneralRe: declaring a global variable Pin
Tara1426-Jun-06 10:19
Tara1426-Jun-06 10:19 
GeneralRe: declaring a global variable Pin
Anilkumar K V26-Jun-06 18:22
Anilkumar K V26-Jun-06 18:22 
GeneralRe: declaring a global variable Pin
Zac Howland26-Jun-06 9:29
Zac Howland26-Jun-06 9:29 
AnswerRe: declaring a global variable Pin
Jun Du26-Jun-06 9:25
Jun Du26-Jun-06 9:25 
TheinstruTara wrote:
then I have to declare it again as extern CString sqla in payroll.cpp (another dialog class)?


Keyword "extern" indicates that this variable has been declared elsewhere in the same module and tells the compiler to use that declaration.

TheinstruTara wrote:
If you want to use CString sqla in all the functions of that particular .cpp file, you declare it in the header file.


That may be what you have been doing, but it's not right. You don't declare varaibles in a header, you only put macros, constants, type definitions (that sort of things) there.

In essense, header is about definition not declaration. People include your header because they want to use your type definitions, not the variables in your module!

Hope this is clearer.


Best,
Jun
GeneralRe: declaring a global variable Pin
Tara1426-Jun-06 9:44
Tara1426-Jun-06 9:44 
GeneralRe: declaring a global variable Pin
Zac Howland26-Jun-06 9:54
Zac Howland26-Jun-06 9:54 
GeneralRe: declaring a global variable Pin
Jun Du26-Jun-06 10:20
Jun Du26-Jun-06 10:20 
GeneralRe: declaring a global variable Pin
Tara1426-Jun-06 10:26
Tara1426-Jun-06 10:26 
GeneralRe: declaring a global variable Pin
David Crow26-Jun-06 9:49
David Crow26-Jun-06 9:49 
GeneralRe: declaring a global variable Pin
Jun Du26-Jun-06 10:27
Jun Du26-Jun-06 10:27 
GeneralRe: declaring a global variable Pin
David Crow26-Jun-06 10:48
David Crow26-Jun-06 10:48 
AnswerRe: declaring a global variable Pin
Michael Dunn26-Jun-06 9:43
sitebuilderMichael Dunn26-Jun-06 9:43 
GeneralRe: declaring a global variable Pin
Tara1426-Jun-06 10:27
Tara1426-Jun-06 10:27 
QuestionPointers... Pin
#hackC++26-Jun-06 8:04
#hackC++26-Jun-06 8:04 
AnswerRe: Pointers... Pin
Jun Du26-Jun-06 8:14
Jun Du26-Jun-06 8:14 
GeneralRe: Pointers... Pin
#hackC++26-Jun-06 8:17
#hackC++26-Jun-06 8:17 
GeneralRe: Pointers... Pin
Jun Du26-Jun-06 8:36
Jun Du26-Jun-06 8:36 
AnswerRe: Pointers... Pin
Roland Pibinger26-Jun-06 8:17
Roland Pibinger26-Jun-06 8:17 
GeneralRe: Pointers... Pin
#hackC++26-Jun-06 8:20
#hackC++26-Jun-06 8:20 
GeneralRe: Pointers... Pin
Zac Howland26-Jun-06 9:04
Zac Howland26-Jun-06 9:04 
AnswerRe: Pointers... Pin
David Crow26-Jun-06 9:11
David Crow26-Jun-06 9:11 

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.