c++11 new Syntax 1:auto keyword
One of the most useful features that c++11 adds is the Auto keyword.
I wonder if you've ever written such a code:
STD::MAP<STD::string, std::vector<std::shared_ptr<std::list<t> > > > map;std:: Map<std::string, std::vector<std::shared_ptr<std::list<t> > > >::iterator it = Map.begin ();
Even more complex templates are nested than this.
In this case, not only is the code lengthy and error prone, but the compilation error message after the error is difficult to read
The use of auto can greatly simplify the writing of the code, but also reduce the possibility of spelling mistakes
STD::MAP<STD::string, std::vector<std::shared_ptr<std::list<t> > > >= Map.begin ();
C++11 New Grammar 2:nullptr
Before nullptr, the null pointer is defined as follows:
#ifdef __cplusplus #define Null 0 #else #define null ((void *) 0) #endif
Because C + + is strongly typed, void * is not implicitly convertible to other pointer types, so the null of C + + is directly defined as 0.
There's a big mistake in this case.
void foo (int i); void foo (char* p);
In this case:
Foo (NULL);
is not clear.
So the nullptr was introduced into the c++11.
Foo (0); foo (nullptr);
Solved the problem.
C++11 New Grammar 2:for loop
The general for loop in C + + is as follows:
std::vector<int> v; for (Auto it = V.begin (); It! = V.end (); it++) {//doanything}
Other languages, such as the For loop in Python, are like this
for inch list: # Do anything
Will cpper feel blue?
So c++11 introduced this:
for (Auto v:vector) { // do anything}
These are some of the most common new grammars in c++11.
Abelkhan Technology Forum: http://abelkhan.com/forum.php, Welcome to Exchange technology
Learn the new grammar in c++11--c++11