E
Eric Kaplan
from the following class it has a static variable
http://www.oniva.com/upload/1356/TestAppWLib.cpp
How do I define a static (Class variable) just like in Java?
static BYTE msgDUMP[5] = { 0xf0, 0x7d, 0x00, 0x47, 0xf7};
static BYTE msgMUTE[6] = { 0xf0, 0x7d, 0x00, 0x32, 0x01, 0xf7};
static BYTE msgUNMUTE[6] = { 0xf0, 0x7d, 0x00, 0x32, 0x00, 0xf7};
right before the constructor
CTestAppWLibDlg::CTestAppWLibDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTestAppWLibDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
====================
is that how people define static (Class variable) in C++?
does people define static variable in .h header file?
what's difference with no static keyword, would that become a global
variable?
I think difference of global var and static variable are:
1) global variable can be access from only the own .cpp file.
2) static variable can be access from any where through the Class name
http://www.oniva.com/upload/1356/TestAppWLib.cpp
How do I define a static (Class variable) just like in Java?
static BYTE msgDUMP[5] = { 0xf0, 0x7d, 0x00, 0x47, 0xf7};
static BYTE msgMUTE[6] = { 0xf0, 0x7d, 0x00, 0x32, 0x01, 0xf7};
static BYTE msgUNMUTE[6] = { 0xf0, 0x7d, 0x00, 0x32, 0x00, 0xf7};
right before the constructor
CTestAppWLibDlg::CTestAppWLibDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTestAppWLibDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
====================
is that how people define static (Class variable) in C++?
does people define static variable in .h header file?
what's difference with no static keyword, would that become a global
variable?
I think difference of global var and static variable are:
1) global variable can be access from only the own .cpp file.
2) static variable can be access from any where through the Class name