Click here to Skip to main content
15,901,373 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionSHFileOperation with SHFILEOPSTRUCT fails when used with vars but works with string literals Pin
bcb_guy25-Jan-12 1:06
bcb_guy25-Jan-12 1:06 
AnswerRe: SHFileOperation with SHFILEOPSTRUCT fails when used with vars but works with string literals Pin
Jochen Arndt25-Jan-12 1:55
professionalJochen Arndt25-Jan-12 1:55 
AnswerRe: SHFileOperation with SHFILEOPSTRUCT fails when used with vars but works with string literals Pin
Richard Andrew x6425-Jan-12 2:06
professionalRichard Andrew x6425-Jan-12 2:06 
AnswerIssue Resolved! (Of Course User Error) Pin
bcb_guy25-Jan-12 17:41
bcb_guy25-Jan-12 17:41 
GeneralRe: Issue Resolved! (Of Course User Error) Pin
Jochen Arndt25-Jan-12 21:20
professionalJochen Arndt25-Jan-12 21:20 
GeneralRe: Issue Resolved! (Of Course User Error) Pin
bcb_guy25-Jan-12 23:29
bcb_guy25-Jan-12 23:29 
GeneralRe: Issue Resolved! (Of Course User Error) Pin
David Crow26-Jan-12 3:06
David Crow26-Jan-12 3:06 
QuestionGet the local drives, scan and retrieve files using visual c++ Pin
amabi25-Jan-12 0:43
amabi25-Jan-12 0:43 
AnswerRe: Get the local drives, scan and retrieve files using visual c++ Pin
David Crow25-Jan-12 3:01
David Crow25-Jan-12 3:01 
QuestionXML Data To C++ Objects Pin
002comp24-Jan-12 22:24
002comp24-Jan-12 22:24 
AnswerRe: XML Data To C++ Objects Pin
Rolf Kristensen26-Jan-12 20:20
Rolf Kristensen26-Jan-12 20:20 
QuestionHow to check if an internet connection exist ? Pin
_Flaviu24-Jan-12 1:13
_Flaviu24-Jan-12 1:13 
AnswerRe: How to check if an internet connection exist ? Pin
Rajesh R Subramanian24-Jan-12 2:07
professionalRajesh R Subramanian24-Jan-12 2:07 
Questionusing extern in C Pin
Sakhalean23-Jan-12 22:53
Sakhalean23-Jan-12 22:53 
AnswerRe: using extern in C Pin
Jochen Arndt23-Jan-12 23:09
professionalJochen Arndt23-Jan-12 23:09 
GeneralRe: using extern in C Pin
Sakhalean23-Jan-12 23:32
Sakhalean23-Jan-12 23:32 
GeneralRe: using extern in C Pin
Jochen Arndt23-Jan-12 23:41
professionalJochen Arndt23-Jan-12 23:41 
AnswerRe: using extern in C Pin
Erudite_Eric24-Jan-12 5:33
Erudite_Eric24-Jan-12 5:33 
AnswerRe: using extern in C Pin
Stefan_Lang24-Jan-12 5:50
Stefan_Lang24-Jan-12 5:50 
GeneralRe: using extern in C Pin
Erudite_Eric24-Jan-12 6:23
Erudite_Eric24-Jan-12 6:23 
GeneralRe: using extern in C Pin
Stefan_Lang24-Jan-12 22:44
Stefan_Lang24-Jan-12 22:44 
GeneralRe: using extern in C Pin
Erudite_Eric25-Jan-12 0:32
Erudite_Eric25-Jan-12 0:32 
AnswerRe: using extern in C Pin
«_Superman_»24-Jan-12 15:37
professional«_Superman_»24-Jan-12 15:37 
I assume what you're trying to do is to create a global variable in Main.cpp and make it read only in other .cpp files?
If so, here is what you can do.

Create the global variable as static in Main.cpp - static int x = 0;
Now create a function in Main.cpp that returns this value - int GetX() { return x; }
Now you can call this function from other .cpp files to get the value of x and also x can only be modified from Main.cpp.

Here you do not need to use the extern keyword at all.
Also to call GetX in other .cpp files, you will need to declare it there - int GetX();
«_Superman 
I love work. It gives me something to do between weekends.


Microsoft MVP (Visual C++)

Polymorphism in C

JokeRe: using extern in C Pin
Peter_in_278024-Jan-12 15:58
professionalPeter_in_278024-Jan-12 15:58 
GeneralRe: using extern in C Pin
Mohibur Rashid24-Jan-12 22:46
professionalMohibur Rashid24-Jan-12 22:46 

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.