Click here to Skip to main content
15,894,646 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: dynamic allocation of arrays [modified] Pin
Sauce!29-Sep-08 21:01
Sauce!29-Sep-08 21:01 
GeneralRe: dynamic allocation of arrays Pin
Iain Clarke, Warrior Programmer30-Sep-08 0:20
Iain Clarke, Warrior Programmer30-Sep-08 0:20 
GeneralRe: dynamic allocation of arrays Pin
Sauce!30-Sep-08 0:55
Sauce!30-Sep-08 0:55 
GeneralRe: dynamic allocation of arrays Pin
Iain Clarke, Warrior Programmer30-Sep-08 1:25
Iain Clarke, Warrior Programmer30-Sep-08 1:25 
GeneralRe: dynamic allocation of arrays Pin
Sauce!30-Sep-08 1:34
Sauce!30-Sep-08 1:34 
GeneralRe: dynamic allocation of arrays Pin
Iain Clarke, Warrior Programmer30-Sep-08 1:48
Iain Clarke, Warrior Programmer30-Sep-08 1:48 
GeneralRe: dynamic allocation of arrays Pin
Sauce!30-Sep-08 2:16
Sauce!30-Sep-08 2:16 
GeneralRe: dynamic allocation of arrays Pin
Iain Clarke, Warrior Programmer30-Sep-08 3:21
Iain Clarke, Warrior Programmer30-Sep-08 3:21 
Header:
class CMyClass
{
public:
    CMyClass ();
    ~CMyClass ();

protected:
   static int g_MyCounter;
};

cpp file:

int CMyClass::g_MyCounter = 0; // initialise it!

CMyClass::CMyClass ()
{
   g_MyCounter++;
}

CMyClass::~CMyClass ();
{
   ASSERT(g_MyCounter); // vulnerable to race conditions in a multithreaded app. Use crit_section if it's that, um, critical
   g_MyCounter--;
}


Given that you have a fixed number per block, I really can't see any point in you doing this for this application though... That static member variable is shared between all instances of CMyClass. I use this technique a lot for registered messages.

eg:
UINT CMyTopSecretClass::m_wm_SomeMessage = ::RegisterWindowMessage ("CMyTopSecretClass::m_wm_SomeMessage");


I hope this helps,

Iain.
GeneralRe: dynamic allocation of arrays [modified] Pin
Sauce!30-Sep-08 5:01
Sauce!30-Sep-08 5:01 
GeneralRe: dynamic allocation of arrays Pin
Iain Clarke, Warrior Programmer30-Sep-08 5:31
Iain Clarke, Warrior Programmer30-Sep-08 5:31 
GeneralRe: dynamic allocation of arrays Pin
Sauce!30-Sep-08 5:43
Sauce!30-Sep-08 5:43 
GeneralRe: dynamic allocation of arrays Pin
Iain Clarke, Warrior Programmer30-Sep-08 6:02
Iain Clarke, Warrior Programmer30-Sep-08 6:02 
GeneralRe: dynamic allocation of arrays Pin
Sauce!2-Oct-08 5:05
Sauce!2-Oct-08 5:05 
GeneralRe: dynamic allocation of arrays [modified] Pin
Sauce!4-Oct-08 2:42
Sauce!4-Oct-08 2:42 
GeneralRe: dynamic allocation of arrays Pin
Sauce!4-Oct-08 5:19
Sauce!4-Oct-08 5:19 
GeneralRe: dynamic allocation of arrays [modified] Pin
Sauce!4-Oct-08 5:34
Sauce!4-Oct-08 5:34 
GeneralRe: dynamic allocation of arrays [modified] Pin
Sauce!4-Oct-08 12:53
Sauce!4-Oct-08 12:53 
GeneralRe: dynamic allocation of arrays Pin
Sauce!17-Oct-08 20:58
Sauce!17-Oct-08 20:58 
Questionno WM_MOUSEHOVER in an edit Pin
followait28-Sep-08 18:58
followait28-Sep-08 18:58 
AnswerRe: no WM_MOUSEHOVER in an edit Pin
Iain Clarke, Warrior Programmer30-Sep-08 0:25
Iain Clarke, Warrior Programmer30-Sep-08 0:25 
QuestionCListCtrl Problem Pin
Dhiraj kumar Saini28-Sep-08 18:53
Dhiraj kumar Saini28-Sep-08 18:53 
AnswerRe: CListCtrl Problem Pin
_AnsHUMAN_ 28-Sep-08 18:59
_AnsHUMAN_ 28-Sep-08 18:59 
AnswerRe: CListCtrl Problem Pin
Naveen28-Sep-08 19:01
Naveen28-Sep-08 19:01 
QuestionWrite a buffer to stringstream Pin
CodingLover28-Sep-08 18:43
CodingLover28-Sep-08 18:43 
AnswerRe: Write a buffer to stringstream Pin
Naveen28-Sep-08 19:04
Naveen28-Sep-08 19:04 

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.