Click here to Skip to main content
15,917,005 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Problem with COLOURREF Pin
Cedric Moonen23-Aug-06 3:18
Cedric Moonen23-Aug-06 3:18 
AnswerRe: Problem with COLOURREF Pin
benjymous23-Aug-06 4:22
benjymous23-Aug-06 4:22 
AnswerRe: Problem with COLOURREF Pin
jk chan23-Aug-06 15:05
jk chan23-Aug-06 15:05 
QuestionHow to initialize a variable in class Pin
9ine23-Aug-06 0:54
9ine23-Aug-06 0:54 
AnswerRe: How to initialize a variable in class Pin
prasad_som23-Aug-06 1:21
prasad_som23-Aug-06 1:21 
AnswerRe: How to initialize a variable in class Pin
toxcct23-Aug-06 1:54
toxcct23-Aug-06 1:54 
AnswerRe: How to initialize a variable in class Pin
Hamid_RT23-Aug-06 2:10
Hamid_RT23-Aug-06 2:10 
AnswerRe: How to initialize a variable in class Pin
Zac Howland23-Aug-06 4:18
Zac Howland23-Aug-06 4:18 
In general, you would initialize member variables as part of the Constructor (either in the implicit parameter list, or in the constructor). For the example you give, you may consider writing it the following way:

// In the header file

class MyClass
{
public:
	MyClass() {}
	~MyClass() {}

	static const char* ms_MyString;
};

// In the implementation file

const char* MyClass::ms_MyString = "0123456789";


This gives you a single copy of the string regardless of the number of objects of this type you have. It will remain constant (that is, you can't change it), and it will remain in the same location in memory for the entire lifetime of your application.

If you need to have an array that you can change, you would initialize it in the constructor:

// In the header file

class MyClass
{
public:
	MyClass() : m_MyString(0) {memset(m_MyOtherString, 0, 100);}
	~MyClass() {}

	char* m_MyString; // pointer-style array
	char m_MyOtherString[100]; // allocated array
};


If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week

Zac

QuestionCFileDialog Filter option Pin
chands23-Aug-06 0:30
chands23-Aug-06 0:30 
AnswerRe: CFileDialog Filter option Pin
Rage23-Aug-06 1:33
professionalRage23-Aug-06 1:33 
GeneralRe: CFileDialog Filter option Pin
chands23-Aug-06 1:43
chands23-Aug-06 1:43 
QuestionRe: CFileDialog Filter option Pin
Hamid_RT23-Aug-06 1:51
Hamid_RT23-Aug-06 1:51 
GeneralRe: CFileDialog Filter option Pin
Rage23-Aug-06 3:14
professionalRage23-Aug-06 3:14 
AnswerRe: CFileDialog Filter option Pin
_AnsHUMAN_ 23-Aug-06 1:36
_AnsHUMAN_ 23-Aug-06 1:36 
QuestionHow to.. Pin
ramanand_bulusu23-Aug-06 0:30
ramanand_bulusu23-Aug-06 0:30 
AnswerRe: How to.. [modified] Pin
mails2dhana23-Aug-06 0:38
mails2dhana23-Aug-06 0:38 
AnswerRe: How to.. Pin
Hamid_RT23-Aug-06 1:51
Hamid_RT23-Aug-06 1:51 
Questionfinding register entries Pin
Kiran Pinjala23-Aug-06 0:22
Kiran Pinjala23-Aug-06 0:22 
AnswerRe: finding register entries Pin
Matt Godbolt23-Aug-06 0:33
Matt Godbolt23-Aug-06 0:33 
GeneralRe: finding register entries Pin
Kiran Pinjala23-Aug-06 1:48
Kiran Pinjala23-Aug-06 1:48 
AnswerRe: finding register entries Pin
Hamid_RT23-Aug-06 1:57
Hamid_RT23-Aug-06 1:57 
QuestionHow to create the behaviour on clicking the menue Pin
yummi23-Aug-06 0:17
yummi23-Aug-06 0:17 
Questiongettimeofday in windows Pin
afpr22-Aug-06 23:32
afpr22-Aug-06 23:32 
AnswerRe: gettimeofday in windows Pin
Matt Godbolt22-Aug-06 23:40
Matt Godbolt22-Aug-06 23:40 
GeneralRe: gettimeofday in windows Pin
afpr23-Aug-06 0:23
afpr23-Aug-06 0:23 

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.