var keyword comes to c++

 

Ok so it’s not the var keyword in c++, but in C++11 it’s called auto.
This is something I love in c#, life would be miserable without it Smile, it’s magnificent especially in linq, infact linq could become quite painful without it (and also dynamic comes in handy in linq).

So where’s the sample?

image

The pDc has local scope and is of type CPaintDC*.

Now don’t be confused with the other place you may have used auto, i.e. back in the early days when we used to be concerned about putting things in registers (before the compilers took over this code generation heavy lifting).
e.g. auto int i = 0;