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. using CList

using CList

Scheduled Pinned Locked Moved C / C++ / MFC
4 Posts 4 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.
  • 1 Offline
    1 Offline
    12Code
    wrote on last edited by
    #1

    Can anyone tell me what's the different between CList<CTime,CTime> m_listTime and CList<CTime,CTime&> m_listTime i used either one of these in my program, can't see the different.

    ;)*12Code

    S T C 3 Replies Last reply
    0
    • 1 12Code

      Can anyone tell me what's the different between CList<CTime,CTime> m_listTime and CList<CTime,CTime&> m_listTime i used either one of these in my program, can't see the different.

      ;)*12Code

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      12Code wrote:

      CList m_listTime

      This version will copy CTime items when you pass them as parameters to list methods like SetAt[^].

      12Code wrote:

      CList m_listTime

      This version will pass a reference to CTime items when you pass them as parameters to list methods like SetAt[^]. I'm not surprised you don't see a difference - there's not much of one in this case. A slight performance issue, but not much else - except that you really want the default value for the second template parameter.

      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

      1 Reply Last reply
      0
      • 1 12Code

        Can anyone tell me what's the different between CList<CTime,CTime> m_listTime and CList<CTime,CTime&> m_listTime i used either one of these in my program, can't see the different.

        ;)*12Code

        T Offline
        T Offline
        toxcct
        wrote on last edited by
        #3

        you see no difference because the differences are underground. the second parameter is meant to tell to CList how it's gonna handle your list elements like. a CTime template parameter tells to use so as methods parameter, that means each time you pass an element to a CList method (such as Add()), it will pass a CTime. that means the parameter will be passed by copy. a CTime& (or even better a const CTime&) template parameter will have you make no changes in your code, but it will handle references, so no copies anymore. the difference between the 2 is in the memory consumption and in the performances of the program.

        [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

        1 Reply Last reply
        0
        • 1 12Code

          Can anyone tell me what's the different between CList<CTime,CTime> m_listTime and CList<CTime,CTime&> m_listTime i used either one of these in my program, can't see the different.

          ;)*12Code

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #4

          As a side note, try to pass a temporary object to the second form and see what happens to your application... :rolleyes:

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          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