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. s it safe to pass CComVariant declared locally ot other function

s it safe to pass CComVariant declared locally ot other function

Scheduled Pinned Locked Moved C / C++ / MFC
question
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.
  • P Offline
    P Offline
    ptr_Electron
    wrote on last edited by
    #1

    Is it safe to pass CComVariant declared locally to other function 1. Can I pass the CommVariant to other function, when not created using new ? 2. Should I free it/delete expecitly some where ? 3. Is it safe ? any precauions ?

    CComVariant comVart;
    comVariant.vt = VT_I4;
    comVariant.intVal = 10;
    SendComVariantToOtherFunction(comVart);
    Thanks in advance!!

    J 1 Reply Last reply
    0
    • P ptr_Electron

      Is it safe to pass CComVariant declared locally to other function 1. Can I pass the CommVariant to other function, when not created using new ? 2. Should I free it/delete expecitly some where ? 3. Is it safe ? any precauions ?

      CComVariant comVart;
      comVariant.vt = VT_I4;
      comVariant.intVal = 10;
      SendComVariantToOtherFunction(comVart);
      Thanks in advance!!

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      ptr_Electron wrote:

      1. Can I pass the CommVariant to other function, when not created using new ?

      Yes.

      ptr_Electron wrote:

      2. Should I free it/delete expecitly some where ?

      No, when not allocated on the heap. When using new, it must be of course freed using delete. Everything else is done by the destructor.

      ptr_Electron wrote:

      3. Is it safe ? any precauions ?

      It is safe. But you must take care when assigning data (type and data must match).

      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