Message from C, C++ talks

July 2019

— Most of the time

— Got it

— 1) why is there using namespace std? this is not a good point to start programming.

2) define max? what the hell man. setting constant values that should be evaluated during compiletime. that's what constexpr are for. and furthermore: max? seriously? thats not a name.

3) why are you looking into an uninitialized variable? thats not a bug, thats not thinking about what you actually want to do.


1) throw out using namespace std and learn where your functions are located in the libs

2) use constexpr instead of macro defs if possible (constexpr int maxAge) consider giving your variables precise names. names matter and expressiveness matters

3) take a pen and some paper and make a graph of your program

Message permanent page

— Also writing complete sentences when asking for someones help is usually considered good-practise ;)


Imo novices are not ready for constexpr. Const should be first, and const is const vars, const refs and const memfuns - a long way to go. They also need to be taught about const-correctness (cause constexpr implies it), which us not the 1st step in c++ learning
const max would be sufficient

— Not ready for constexpr, but for a marco? i really doubt that

— Macro vars are very simple and dumb. Nothing to explane but one word - define

— A constexpr int maxAge{100}; is also really dumb

— I see a lot of senior code with magic number defines in it, and i can tell you... the bugs are exactly there

Message permanent page

— Yeah, then they might do

constexpr std::string prefix{ "$HOME/myspace/" };

— I trust. But defines are much simplier as constexpr

— But constexpr are typesafe, and thats one of the most important features about c++

— How long your explanation of that would be?

— My point is, const is enough for a novice

— Mh