Re: Question on auto_ptr, Which function will call first?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • James Kanze

    Re: Question on auto_ptr, Which function will call first?

    On Oct 6, 3:59 pm, microcassanova <mangal.pa...@g mail.comwrote:
    On Oct 6, 5:25 pm, James Kanze <james.ka...@gm ail.comwrote:
    On Oct 5, 9:39 pm, Hendrik Schober <spamt...@gmx.d ewrote:
    James Kanze wrote:
    On Oct 3, 6:17 pm, Victor Bazarov <v.Abaza...@com Acast.netwrote:
    The 'operator new' function is the class-wide allocation
    function. Before any object of that class can be constructed
    in free store, the memory has to be allocated. That's why the
    allocation happens before the construction.
    Just a nit, but that last sentence applies to all objects, not
    just those dynamically allocated. One of the particularities of
    C++ is that there is NO syntax for calling a constructor without
    formally allocating memory. [...]
    I don't doubt that you're right, but I'd like to know
    what this
    std::string("hu h?")
    is if it's not the explicit invocation of a constructor.
    According to the standard, it's an "Explicit type conversion
    (functional notation)". Which in this particular case,
    actually works well as a nomenclature: the semantics are
    exactly the same as those of ``static_cast< std::string >(
    "huh?" )''. According to the standard, ``std::string() ''
    and ``std::string( 5, '*' )'' are also "Explicit type
    conversion (functional notation)", which I find a little bit
    more difficult to accept. You can't really call them an
    "explicit invocation of a constructor", however, since they
    do more; I rather like "explicit creation of a temporary".
    But I'm afraid I have very little, if any, influence on what
    people call things.
    the COnstructor TraceHeap should have been
    explict TraceHeap(int i)
    {
    }
    explict keyword this prevents data loss . All parameterised
    constructor should have explicit keyword
    I presume you mean explicit, but what does that change? And
    what is the relationship with data loss. (Most of my
    constructors are declared explicit, but the reason has nothing
    to do with data loss. And doesn't change anything in the above,
    since we're talking about explicit type conversions here
    anyway.)

    --
    James Kanze (GABI Software) email:james.kan ze@gmail.com
    Conseils en informatique orientée objet/
    Beratung in objektorientier ter Datenverarbeitu ng
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Working...