r/CodingForBeginners • u/samosa285 • 9d ago
Day 5 of learning C++(first program)
Today , i finally completed my 1st module on learncpp.com
Learnt literals , operators , expressions made two programs(only took ss of one Program)(and yeah I added new line character afterwards)
Well as I know some coding so it was pretty easy
Tbh the hardest part was to figure out what CMakeList is in CLion
Spend more time in figuring and setting that up rather than coding
+ If anyone know how to like automatically add executable in CMakeList rather than adding manually , well adding manually is not a problem tho but still
Tomorrow will be hectic day(college assignments and practicals) still will try to do some coding.
2
u/Tiaoshi 9d ago
Nice work, though keep in mind, because you are using namespace std, you don’t need to add std:: in front of anything within the std library. Though if you wish to continue to do so, there is nothing wrong with it, just can save you a bit of typing by omitting it (while having “ using namespace std; “
1
u/samosa285 8d ago
Tbh I didn't know about what using namespace std does I was just messing around Still thanks!!!!
1
u/Psilocybe_Fanaticus 9d ago
Why are you using std::cout when you are already using “using namespace std”?
1
u/samosa285 8d ago
Tbh I didn't know about what using namespace std does I was just messing around
1
u/Psilocybe_Fanaticus 8d ago
It pretty much removes the need to type std::cout
If you use multiple libraries (in the future), do not use this. Always write it out and completely omit “using workspace std”1
1
u/Traditional_Vast9419 9d ago
CMake is just a build system. I'd recommend just using Make or compiler commands until you actually have a program that's ten thousand lines long.
1
1
u/No-Wealth5392 5d ago
actually its a meta build system and just orchestrates files and configurations for the actual build system you chose
2
2
u/XIA_Biologicals_WVSU 4d ago
Cool. I'm learning Java. Seeing how different languages perform different operations is cool.
1
4
u/kutac56 9d ago
You can do
int x;instead ofint x {};, you are using namespace std and then still typing std:: and you also don't need cmake as that is mainly for cross platform building which is not necessary for such simple things (compile withg++ foo.cpp -o foo)