why auto main() -> int vs int main() [duplicate]

is there a purpose for having auto main() -> int rather than just int main()? int main() is less characters, but I see a lot of modern cpp examples using the former rather than the latter. Is there some sort of benefit to this?

  • 7

    I see a lot of modern cpp projects using the former rather than the latter.” Do you? Can you point some out?

    – 

  • In C++ projects from TypeScript programmers, maybe.

    – 

  • 1

    There is no purpose. It is just a preference that some C++ programmers have for one over the other. Both mean the same thing.

    – 

  • 1

    It’s also often just a way to show off “I know c00l C++ codez” stuff.

    – 

  • 1

    Some people belive that consistency is the most important thing in a program (an OCD effect, possibly). So if you have to use a trailing return type in a few cases, you just use it everywhere. Problem solved!

    – 




Leave a Comment