Click here to Skip to main content
16,005,376 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Color one coloumn text of ListCotrol ! Pin
Le@rner23-Nov-10 1:23
Le@rner23-Nov-10 1:23 
GeneralRe: Color one coloumn text of ListCotrol ! Pin
decoder_8523-Nov-10 23:18
decoder_8523-Nov-10 23:18 
GeneralRe: Color one coloumn text of ListCotrol ! Pin
Le@rner24-Nov-10 0:03
Le@rner24-Nov-10 0:03 
GeneralRe: Color one coloumn text of ListCotrol ! Pin
decoder_8524-Nov-10 17:10
decoder_8524-Nov-10 17:10 
QuestionHelp for EditBox control ! Pin
Le@rner26-Aug-08 23:44
Le@rner26-Aug-08 23:44 
AnswerRe: Help for EditBox control ! Pin
Naveen26-Aug-08 23:53
Naveen26-Aug-08 23:53 
GeneralRe: Help for EditBox control ! Pin
Le@rner26-Aug-08 23:58
Le@rner26-Aug-08 23:58 
Questionusing reference as member variable is dangerous? Pin
George_George26-Aug-08 23:42
George_George26-Aug-08 23:42 
Hello everyone,


For the pattern, using reference variable as internal data member variables, I have some cercerns and want to listen to your advice whether it is real issues. I showed simple code to illustrate my idea.

My concerns are,

1. if the _buf is binded to a local variable (e.g. a local string variable), then if instance of Foo lives longer than the local variable, is it safe?

2. if the _buf is binded to a heap variable, and it is released some time but Foo does not the release operation, then using _buf is not safe?

class Foo
{
private:
	string& _buf;
public:
	Foo (string& input): _buf (input)
	{
	}
};

int main()
{
	// 1. using local variable to construct
	// string a = xxx;
	// Foo (a);

	// 2. release earlier
	// string* a = new string(xxx);
	// Foo (*a);
	// delete a;

	return 0;
}



thanks in advance,
George
AnswerRe: using reference as member variable is dangerous? Pin
Roger Stoltz27-Aug-08 0:03
Roger Stoltz27-Aug-08 0:03 
GeneralRe: using reference as member variable is dangerous? Pin
George_George27-Aug-08 1:47
George_George27-Aug-08 1:47 
AnswerRe: using reference as member variable is dangerous? Pin
Roger Stoltz27-Aug-08 2:16
Roger Stoltz27-Aug-08 2:16 
GeneralRe: using reference as member variable is dangerous? Pin
George_George27-Aug-08 2:18
George_George27-Aug-08 2:18 
AnswerRe: using reference as member variable is dangerous? Pin
SandipG 27-Aug-08 0:26
SandipG 27-Aug-08 0:26 
GeneralRe: using reference as member variable is dangerous? Pin
Roger Stoltz27-Aug-08 1:32
Roger Stoltz27-Aug-08 1:32 
GeneralRe: using reference as member variable is dangerous? Pin
George_George27-Aug-08 1:49
George_George27-Aug-08 1:49 
GeneralRe: using reference as member variable is dangerous? Pin
George_George27-Aug-08 1:48
George_George27-Aug-08 1:48 
GeneralRe: using reference as member variable is dangerous? Pin
SandipG 27-Aug-08 2:02
SandipG 27-Aug-08 2:02 
GeneralRe: using reference as member variable is dangerous? Pin
George_George27-Aug-08 2:17
George_George27-Aug-08 2:17 
Questiondisplaying output to edit boxes like printf Pin
l_d26-Aug-08 23:23
l_d26-Aug-08 23:23 
AnswerRe: displaying output to edit boxes like printf Pin
toxcct26-Aug-08 23:27
toxcct26-Aug-08 23:27 
AnswerRe: displaying output to edit boxes like printf Pin
_AnsHUMAN_ 26-Aug-08 23:28
_AnsHUMAN_ 26-Aug-08 23:28 
AnswerRe: displaying output to edit boxes like printf Pin
Perspx26-Aug-08 23:31
Perspx26-Aug-08 23:31 
AnswerRe: displaying output to edit boxes like printf Pin
CPallini26-Aug-08 23:33
mveCPallini26-Aug-08 23:33 
GeneralRe: displaying output to edit boxes like printf Pin
l_d27-Aug-08 0:07
l_d27-Aug-08 0:07 
GeneralRe: displaying output to edit boxes like printf Pin
_AnsHUMAN_ 27-Aug-08 0:26
_AnsHUMAN_ 27-Aug-08 0:26 

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.