I'm learning new of c++. In my text book, there is very simple example this.
int* ip = nullptr; // (ok)
int* ip1{}; // (error)
int* ip2{nullptr}; // (error)
unique_ptr<double> dp{new double}; // (error)
But I got this error with build it.
/Users/bsdo/projects/CPlus/modernbook/include/basis.cpp:81:30: error: expected ';' at end of declaration
unique_ptr<double> dp{new double};
^
;
In file included from /Users/bsdo/projects/CPlus/modernbook/main.cpp:2:
/Users/bsdo/projects/CPlus/modernbook/include/basis.cpp:81:30: error: expected ';' at end of declaration
unique_ptr<double> dp{new double};
^
;
/Users/bsdo/projects/CPlus/modernbook/main.cpp:10:13: error: expected ';' at end of declaration
int* ip1{nullptr};
^
;
Why only curly brace literal throw error??
My env is Mac book pro 2015, Cmake-3.11, Apple LLVM version 9.1.0 (clang-902.0.39.1).