2014 dxdy logo

Научный форум dxdy

Математика, Физика, Computer Science, Machine Learning, LaTeX, Механика и Техника, Химия,
Биология и Медицина, Экономика и Финансовая Математика, Гуманитарные науки




На страницу Пред.  1, 2
 
 Re: C++ база
Сообщение06.02.2016, 10:56 
Аватара пользователя
Munin в сообщении #1097178 писал(а):
Не должен.

Предложенный вами вариант инициализации
Munin в сообщении #1097134 писал(а):
Используется синтаксис C++
string str ();
стандартом не предусмотрен, но синтаксически совпадает с объявлением прототипа функции.
ISO/IEC 14882:2011 писал(а):
12.6.1 Explicit initialization

An object of class type can be initialized with a parenthesized expression-list, where the expression-list is construed as an argument list for a constructor that is called to initialize the object. Alternatively, a single assignment-expression can be specified as an initializer using the = form of initialization. Either direct-initialization semantics or copy-initialization semantics apply; see 8.5. [ Example:
struct complex {
complex();
complex(double);
complex(double,double);
};

complex sqrt(complex,complex);

complex a(1); // initialize by a call of
// complex(double)

complex b = a; // initialize by a copy of a

complex c = complex(1,2); // construct complex(1,2)
// using complex(double,double)
// copy/move it into c

complex d = sqrt(b,c); // call sqrt(complex,complex)
// and copy/move the result into d

complex e; // initialize by a call of
// complex()

complex f = 3; // construct complex(3) using
// complex(double)
// copy/move it into f

complex g = { 1, 2 }; // initialize by a call of
// complex(double, double)
—end example ]

Возможно, вы имели ввиду, что в этом стандарте появился ещё один способ инициализации — при помощи фигурных скобок. Тогда ваш вариант должен быть:
Используется синтаксис C++
string str {};
но мой компилятор такой способ не поддерживает.

 
 
 [ Сообщений: 16 ]  На страницу Пред.  1, 2


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group