In articles on Habré already concerned standard C ++ 0x, and in particular lambda expressions. I wanted to write more about a couple of changes and additions that will be made in C ++. And without further ado to the case.int a = 7.3; // int
void func( int );
func(5.6); //
int x1 = {7.3}; // -
double d = 7;
int x2 {d}; // ,
char x3{7}; //
vector< int > vi = { 1, 2.3, 4, 5.6 }; // ,
class X
{
int a;
validate( int x)
{
if (0<x && x<=max) a=x;
else throw bad_X(x);
}
public :
X( int x) // int
{
validate(x);
}
X() // -
{
validate(42);
}
X( string s) // string
{
int x = lexical_cast< int >(s);
validate(x);
}
// ...
};
class X
{
int a;
public :
X( int x) // int
{
if (0<x && x<=max) a=x;
else throw bad_X(x);
}
X() :X{42} { } // -
X( string s) :X{lexical_cast< int >(s)} { } // string
// ...
}
char * p = nullptr;
int * q = nullptr;
char * p2 = 0; // -
void f( int ); // int
void f( char *); // char*
f(0); // f(int) -
f(nullptr); // f(char*) -
void g( int );
g(nullptr); //: nullptr int
int i = nullptr; //
Source: https://habr.com/ru/post/69313/
All Articles