+ 1

How to use C++ style Arrays?

Why can't the following example compile.. int x; cin>>x; std::array<int,x>{}; Why doesn't it except x??How can i make it work..??

8th Dec 2018, 7:46 AM
Mensch
Mensch - avatar
4 Antworten
+ 5
You should make it constant #include <iostream> #include <array> using namespace std; int main() { const int x=5; array<int,x> check{1,2,3,4,5}; return 0; }
8th Dec 2018, 8:02 AM
ShortCode
+ 2
Can you show the code?
8th Dec 2018, 7:49 AM
ShortCode
+ 2
ShortCode thanks..
8th Dec 2018, 8:09 AM
Mensch
Mensch - avatar
8th Dec 2018, 7:57 AM
Mensch
Mensch - avatar