Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Call ctor in place of function argument

Call ctor in place of function argument

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mr Brainley
    wrote on last edited by
    #1

    I have this line of code :

    TargetList.push_back(CSTREAMS(*(SrcList[i])));

    where CSTREAMS is a userdefined class and TargetList is a vector. So i'm just calling the constructor without the new keyword. I think this creates a temporary object, wich is copied by the vector and then destroeyd, so no memoryleak. Is this correct ?

    CPalliniC 1 Reply Last reply
    0
    • M Mr Brainley

      I have this line of code :

      TargetList.push_back(CSTREAMS(*(SrcList[i])));

      where CSTREAMS is a userdefined class and TargetList is a vector. So i'm just calling the constructor without the new keyword. I think this creates a temporary object, wich is copied by the vector and then destroeyd, so no memoryleak. Is this correct ?

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      Yes.

      In testa che avete, signor di Ceprano?

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups