c++ - Any reason to use (MFC) CList rather than CList? -


I have learned some guidelines that all of us have always used Const to pass a variable from one context , As if func console T & A) and I know that there is another template parameter in CList one ARG_TYPE . I will use ARG_TYPE as its parameter type CList :: AddTail (like ARG_TYPE item)

I have shown in the sample code that it His second template uses the non-type type as argument I have any reason to like non-type type as parameter type?

CList & lt; String, and String & gt; a; vs CList & lt; String, const & amp; String & gt; B;

Any suggestions would be helpful thanks.

Programming without CRT is like driving without the C ++ safety belt.

1. It prevents you from changing the variable,

2. This prevents you from assigning accidental variables

3. Acceptance Const Reference By the argument gives you the ability to pass the value with reference to the security of passing by value

At the same time, the compiler can generate more efficient code because it knows what is the position of the variable / function The time will be. If you are writing tight C ++ code, then this is good.

For the sake of your reference I have read the effect of discontent in this article, but recommended its use accurately.



Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -