Click here to Skip to main content
15,903,388 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Embedded C++ 3.0 Member Variables Pin
Bill Wilson14-Aug-02 9:50
Bill Wilson14-Aug-02 9:50 
GeneralRe: Embedded C++ 3.0 Member Variables Pin
Like2Byte14-Aug-02 10:01
Like2Byte14-Aug-02 10:01 
GeneralRe: Embedded C++ 3.0 Member Variables Pin
Bill Wilson14-Aug-02 10:40
Bill Wilson14-Aug-02 10:40 
QuestionIs this bad design (CComVariant) ? Pin
Todd Smith14-Aug-02 8:27
Todd Smith14-Aug-02 8:27 
AnswerRe: Is this bad design (CComVariant) ? Pin
Shog914-Aug-02 10:01
sitebuilderShog914-Aug-02 10:01 
AnswerRe: Is this bad design (CComVariant) ? Pin
Bill Wilson14-Aug-02 10:51
Bill Wilson14-Aug-02 10:51 
GeneralRe: Is this bad design (CComVariant) ? Pin
Todd Smith14-Aug-02 12:57
Todd Smith14-Aug-02 12:57 
GeneralRe: Is this bad design (CComVariant) ? Pin
Bill Wilson14-Aug-02 13:13
Bill Wilson14-Aug-02 13:13 
No. they all do the same thing. I stepped into them also and thought I saw what you said.

		CComVariant result = buf;

executes

#ifndef OLE2ANSI
	CComVariant(LPCSTR lpszSrc)
	{
		vt = VT_EMPTY;
		*this = lpszSrc;
	}
#endif

		CComVariant result2(buf);
executes the same
		CComVariant result3;
executes 
	CComVariant()
	{
		vt = VT_EMPTY;
	}

		result3 = buf;
executes 
	#ifndef OLE2ANSI
	CComVariant& operator=(LPCSTR lpszSrc)
	{
		USES_CONVERSION;
		InternalClear();
		vt = VT_BSTR;
		bstrVal = ::SysAllocString(A2COLE(lpszSrc));

		if (bstrVal == NULL && lpszSrc != NULL)
		{
			vt = VT_ERROR;
			scode = E_OUTOFMEMORY;
		}
		return *this;
	}
	#endif

Then I looked closer and stepped deeper and found they all ended up executing the = operator code! It does allocate memory.


This line of code from the constructor

		*this = lpszSrc;
executes the = operator code shown above. So all come out the same.


The only caveat I see is that you may not have OLE2ANSI defined.

Make sense?
GeneralRe: Is this bad design (CComVariant) ? Pin
Todd Smith14-Aug-02 13:17
Todd Smith14-Aug-02 13:17 
GeneralRe: Is this bad design (CComVariant) ? Pin
Michael Dunn14-Aug-02 15:02
sitebuilderMichael Dunn14-Aug-02 15:02 
GeneralRe: Is this bad design (CComVariant) ? Pin
Bill Wilson15-Aug-02 6:06
Bill Wilson15-Aug-02 6:06 
GeneralRe: Is this bad design (CComVariant) ? Pin
Michael Dunn15-Aug-02 7:22
sitebuilderMichael Dunn15-Aug-02 7:22 
GeneralRe: Is this bad design (CComVariant) ? Pin
Bill Wilson15-Aug-02 7:58
Bill Wilson15-Aug-02 7:58 
GeneralRe: Is this bad design (CComVariant) ? Pin
Philippe Mori15-Aug-02 10:13
Philippe Mori15-Aug-02 10:13 
GeneralRe: Is this bad design (CComVariant) ? Pin
Bill Wilson16-Aug-02 7:32
Bill Wilson16-Aug-02 7:32 
GeneralRe: Is this bad design (CComVariant) ? Pin
Philippe Mori16-Aug-02 16:49
Philippe Mori16-Aug-02 16:49 
AnswerRe: Is this bad design (CComVariant) ? Pin
Michael Dunn14-Aug-02 15:04
sitebuilderMichael Dunn14-Aug-02 15:04 
GeneralRe: Is this bad design (CComVariant) ? Pin
Philippe Mori16-Aug-02 17:15
Philippe Mori16-Aug-02 17:15 
GeneralStack Question Pin
Nick Parker14-Aug-02 8:21
protectorNick Parker14-Aug-02 8:21 
GeneralRe: Stack Question Pin
Chris Losinger14-Aug-02 8:24
professionalChris Losinger14-Aug-02 8:24 
GeneralRe: Stack Question Pin
Nick Parker14-Aug-02 8:26
protectorNick Parker14-Aug-02 8:26 
GeneralRe: Stack Question Pin
Chris Losinger14-Aug-02 8:30
professionalChris Losinger14-Aug-02 8:30 
GeneralRe: Stack Question Pin
Nick Parker14-Aug-02 8:31
protectorNick Parker14-Aug-02 8:31 
GeneralRe: Stack Question Pin
Chris Losinger14-Aug-02 8:36
professionalChris Losinger14-Aug-02 8:36 
GeneralRe: Stack Question Pin
Nick Parker14-Aug-02 8:44
protectorNick Parker14-Aug-02 8:44 

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.