Click here to Skip to main content
16,012,015 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Motion Detection Pin
Programm3r28-May-07 19:53
Programm3r28-May-07 19:53 
AnswerRe: Motion Detection Pin
Hamid_RT28-May-07 20:03
Hamid_RT28-May-07 20:03 
AnswerRe: Motion Detection Pin
Amar Sutar28-May-07 21:10
Amar Sutar28-May-07 21:10 
QuestionDeclaring Global Variable Pin
Anurag Gandhi28-May-07 19:21
professionalAnurag Gandhi28-May-07 19:21 
AnswerRe: Declaring Global Variable Pin
autodebug28-May-07 19:33
autodebug28-May-07 19:33 
GeneralRe: Declaring Global Variable Pin
Anurag Gandhi28-May-07 19:39
professionalAnurag Gandhi28-May-07 19:39 
GeneralRe: Declaring Global Variable Pin
jhwurmbach28-May-07 22:41
jhwurmbach28-May-07 22:41 
AnswerRe: Declaring Global Variable Pin
Matthew Faithfull28-May-07 22:55
Matthew Faithfull28-May-07 22:55 
No, Don't put your global in a .h file unless it is a static inside a class. If it's a straight global at file scope you will get a different copy in every compilation unit (.cpp file) that includes the header, not a global variable at all!
Instead put the global in one .cpp file and then declare it as extern in any other where you want to use it, this is the old fashioned 'C' way but it still works.

//some.cpp<br />
//...<br />
#include "stdafx.h"<br />
//...<br />
int g_MyGlobal = 5;<br />
//...


//other.cpp<br />
//...<br />
#include "stdafx.h"<br />
//...<br />
extern int g_Myglobal;<br />
//...<br />
//Now you can write code here that uses g_MyGlobal, value will be 5.


This is considered very naughty these days as globals are bad Objects Dead | X| . You could consider using a Singleton pattern class instance or static class members for this sort of data.;)



Nothing is exactly what it seems but everything with seems can be unpicked.

AnswerRe: Declaring Global Variable Pin
Nelek29-May-07 1:23
protectorNelek29-May-07 1:23 
QuestionASSERT(m_pCtrlSite == NULL) error on activex addition Pin
shivditya28-May-07 16:44
shivditya28-May-07 16:44 
AnswerRe: ASSERT(m_pCtrlSite == NULL) error on activex addition Pin
Garth J Lancaster29-May-07 1:22
professionalGarth J Lancaster29-May-07 1:22 
AnswerRe: ASSERT(m_pCtrlSite == NULL) error on activex addition Pin
Garth J Lancaster30-May-07 0:58
professionalGarth J Lancaster30-May-07 0:58 
QuestionTitle bar Pin
Aint28-May-07 15:33
Aint28-May-07 15:33 
AnswerRe: Title bar Pin
Naveen28-May-07 15:40
Naveen28-May-07 15:40 
GeneralRe: Title bar Pin
Aint28-May-07 17:07
Aint28-May-07 17:07 
GeneralRe: Title bar Pin
Naveen28-May-07 17:16
Naveen28-May-07 17:16 
QuestionBluetooth and WinSocks problem Pin
(Steven Hicks)n+128-May-07 10:45
(Steven Hicks)n+128-May-07 10:45 
AnswerRe: Bluetooth and WinSocks problem Pin
Mark Salsbery28-May-07 13:28
Mark Salsbery28-May-07 13:28 
GeneralRe: Bluetooth and WinSocks problem Pin
(Steven Hicks)n+128-May-07 13:43
(Steven Hicks)n+128-May-07 13:43 
GeneralRe: Bluetooth and WinSocks problem Pin
Mark Salsbery28-May-07 13:52
Mark Salsbery28-May-07 13:52 
GeneralRe: Bluetooth and WinSocks problem Pin
(Steven Hicks)n+128-May-07 14:48
(Steven Hicks)n+128-May-07 14:48 
GeneralRe: Bluetooth and WinSocks problem Pin
Mark Salsbery28-May-07 14:53
Mark Salsbery28-May-07 14:53 
GeneralRe: Bluetooth and WinSocks problem Pin
(Steven Hicks)n+128-May-07 15:26
(Steven Hicks)n+128-May-07 15:26 
GeneralRe: Bluetooth and WinSocks problem Pin
Mark Salsbery28-May-07 15:54
Mark Salsbery28-May-07 15:54 
QuestionSetWindowsHookEx() hook procedure in DLL Pin
Perspx28-May-07 10:25
Perspx28-May-07 10:25 

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.