Re: Unmanaged C++ object lifetime

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Bob Altman (rda_at_nospam.com)
Date: 03/13/05


Date: Sun, 13 Mar 2005 14:24:56 -0800

Thanks a million for the quick answer. That raises the obvious question of
why a copy of my object is given to stack.push() rather than a reference to
it. Intellisense tells me that the function signature is:

  void std::stack<string>::push(const std::stack<string>::value_type & _Val)

As I read this gibberish, it looks like my variable is being passed by
reference to the push() routine. I would have expected the string that was
given to my function by reference to be given to push() by reference, not by
value (which would create a copy of the string).



Relevant Pages

  • Re: Complex Specified Information - Pitman Formula
    ... Therefore a significant match between a reference and a test ... string is good evidence of non-random production. ... and there are no finite algorithms to compute their digits. ... probabilities of the different symbols the information source can produce. ...
    (talk.origins)
  • Re: String Reference Type
    ... All unary and binary operators have predefined implementations that are ... Therefore its always allocated in the heap and a variable of string ... As with all classes in this case y and x both reference the same String ... language depandant matter as below. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Abstract class variables question
    ... But as I think you've seen elsewhere in this thread, a value type can exist inside a class and in that case the value type is stored in the heap with the rest of the class instance. ... But as far as the "faster" goes, yes...to some extent value types have less overhead than reference types, and so can perform better in certain cases. ... Well, that would be true for a string object too, if there was any way to actually change a string. ... Seriously though, it is practically always the case that when you are writing an assignment to a reference, you're replacing the reference held by the variable. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Measurement of pitch
    ... as the method used by the Pythagoreans. ... of these reference units in the quantity to be measured. ... vibrating string seems as good as anything. ... The string or pendulum in question could no doubt be specified exactly, ...
    (sci.physics)
  • Re: Abstract class variables question
    ... I think I understand boxing a little better now. ... the object that is on the heap. ... value types are copied to the heap and made into an object and reference ... String types are already reference types and all we are doing when we do ...
    (microsoft.public.dotnet.languages.csharp)