The code seeplus wrote requires at most C++11, for the variable initialization on lines 5-6. That is "uniform initialization."
Everything else predates C++11.
Depending on what version of Dev-C++ being used C++11 is possible. Nothing higher. No C++14/17/20.
The original Bloodshed version is the only version I know of that would choke on that code. Orwell's version uses TDM-GCC 4.9.2. That is almost as old as dirt, though it still can compile without a hitch the above code. I know, I tried it in my Orwell Dev-C++.
I can't remember if ISO C++11 is the default when starting a new console project, with my copy it is.
The code lastchance wrote is also error-free in Orwell Dev-C++ as well.
Check your project options. Compiler, code generation, language standard. If it isn't ISO C++11 then change it.
There are two newer ports of the Dev-C++ IDE, Red Panda and Embarcadero. The Embarcadero port uses TDM-GCC 9.2.0, Red Panda uses WinGW64-W64 GCC 10.2.
Neither of the newer Dev-C++ ports will install on my Win10x64 development machine, so I can't really say if they are better than Orwell's outdated version.
One problem with Dev-C++ is trying to install a newer version of the compiler isn't easy, if at all possible. I've tried in the past and couldn't do it without wrecking the original preinstalled compiler. That made Dev-C++ unusable.
There are other free IDEs available, the two common ones for Windows are Visual Studio 2019/2022 and Code::Blocks. Getting and using a C++20 compliant compiler is easy. With VS there are updates that can be applied, C::B can be tweaked to use a different compiler. My copy of C::B uses the MSYS2 MinGW compiler that is updated to the latest MinGW version.
|the code u sent, cant run in this IDE. What should I do?|
1. Dump Dev-C++ and get a different IDE, if possible. Even the dinosaurs wouldn't use Dev-C++ it is so old.
2. MikeyBoy gave very good advice. Learning how to deal with problem(s) yourself instead of just saying "cant run" or "get errors" and expecting others to be mind-readers is only hurting YOU.
The Zero-th rule is "Write Your Own Code FIRST." Just dumping your assignment and expecting others to do the work for you, for free, doesn't promote learning how to program.
You show us code you've written, explain IN DETAIL problems you are having, will go a long way to being a better programmer.
And most people here will be eager to help since you've taken the time to not be a code leech.