Click here to Skip to main content
15,886,110 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: Changing Title of an SDI appliction Pin
H.Brydon19-Sep-13 20:41
professionalH.Brydon19-Sep-13 20:41 
Questiontrouble with a safe array of variants Pin
jeffery c9-Aug-13 8:56
jeffery c9-Aug-13 8:56 
QuestionPassing CString Pin
bkelly1322-Jul-13 16:31
bkelly1322-Jul-13 16:31 
AnswerRe: Passing CString Pin
Richard MacCutchan22-Jul-13 20:57
mveRichard MacCutchan22-Jul-13 20:57 
AnswerRe: Passing CString Pin
pasztorpisti22-Jul-13 23:44
pasztorpisti22-Jul-13 23:44 
GeneralRe: Passing CString Pin
bkelly1323-Jul-13 16:15
bkelly1323-Jul-13 16:15 
GeneralRe: Passing CString Pin
pasztorpisti24-Jul-13 0:43
pasztorpisti24-Jul-13 0:43 
GeneralRe: Passing CString Pin
H.Brydon19-Sep-13 20:58
professionalH.Brydon19-Sep-13 20:58 
Your analysis is a bit flawed.

First of all, you don't need to empty the string before populating it:
bkelly13 wrote:
C++
<br />
void B( CString &some_string );  // (spelling error fixed)<br />
{<br />
  some_string.empty();  // this line is unnecessary<br />
  some_string = internal_string;<br />
}<br/><br />

There are several things that happen in this (fixed) code that don't happen in the 'first call' version. When calling the API, there is more setup on the part of the caller. A CString variable needs to exist already, and API setup makes sure that it is either empty or ref count is zero (and writable). Assuming that internal_string is another CString, no copying takes place. The some_string object's header info is updated to duplicate the same info in internal_string, and the ref count is incremented. If internal_string is 1MB in size, only a pointer and counter are changed (ie. no copying).

Again, if internal_string is a CString, a similar process also happens in your 'first call' code (ie. no copying).

If internal_string is a (const?) char* or (const?) char[] or something else that looks like one of those, then a copy needs to take place for both versions of the code.
Windows 8 is the resurrected version of Microsoft Bob. The only thing missing is the Fisher-Price logo.
- Harvey

AnswerRe: Passing CString Pin
Krishnakumartg13-Aug-13 6:43
Krishnakumartg13-Aug-13 6:43 
AnswerRe: Passing CString Pin
Manoj Kumar Rai21-Aug-13 12:29
professionalManoj Kumar Rai21-Aug-13 12:29 
Questionchang folder's icon Pin
swing001016-Jul-13 0:33
swing001016-Jul-13 0:33 
QuestionCOM technology and use Pin
marisha.u12-Jul-13 9:53
marisha.u12-Jul-13 9:53 
AnswerRe: COM technology and use Pin
Richard MacCutchan12-Jul-13 22:06
mveRichard MacCutchan12-Jul-13 22:06 
AnswerRe: COM technology and use Pin
pasztorpisti13-Jul-13 7:58
pasztorpisti13-Jul-13 7:58 
GeneralRe: COM technology and use Pin
marisha.u15-Jul-13 4:31
marisha.u15-Jul-13 4:31 
GeneralRe: COM technology and use Pin
pasztorpisti15-Jul-13 4:48
pasztorpisti15-Jul-13 4:48 
AnswerRe: COM technology and use Pin
yusif muffed ektilat25-Aug-13 9:19
professionalyusif muffed ektilat25-Aug-13 9:19 
SuggestionHelp : learn ATL, STL and COM Pin
shanmugarajaa8-Jul-13 18:59
shanmugarajaa8-Jul-13 18:59 
GeneralRe: Help : learn ATL, STL and COM Pin
Richard MacCutchan8-Jul-13 21:12
mveRichard MacCutchan8-Jul-13 21:12 
GeneralRe: Help : learn ATL, STL and COM Pin
Jonathan Davies8-Jul-13 22:39
Jonathan Davies8-Jul-13 22:39 
GeneralRe: Help : learn ATL, STL and COM Pin
Ajay_Tiwari3-Sep-13 0:18
Ajay_Tiwari3-Sep-13 0:18 
QuestionHow can I get the ATL Headers for free? Pin
Louai Haimour6-Jul-13 23:37
Louai Haimour6-Jul-13 23:37 
AnswerRe: How can I get the ATL Headers for free? Pin
Richard MacCutchan7-Jul-13 1:23
mveRichard MacCutchan7-Jul-13 1:23 
QuestionChakra: IActiveScript::GetScriptDispatch() fails with E_OUTOFMEMORY Pin
imagiro3-Jul-13 22:13
imagiro3-Jul-13 22:13 
QuestionActiveX in ActiveX problem Pin
leisuregame1-Jul-13 22:29
leisuregame1-Jul-13 22:29 

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.