using CList
-
Can anyone tell me what's the different between
CList<CTime,CTime>
m_listTime andCList<CTime,CTime&>
m_listTime i used either one of these in my program, can't see the different.;)*12Code
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
-
Can anyone tell me what's the different between
CList<CTime,CTime>
m_listTime andCList<CTime,CTime&>
m_listTime i used either one of these in my program, can't see the different.;)*12Code
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]
-
Can anyone tell me what's the different between
CList<CTime,CTime>
m_listTime andCList<CTime,CTime&>
m_listTime i used either one of these in my program, can't see the different.;)*12Code
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]