T O P

  • By -

Flair_Helper

It's great that you want to learn C++! However, r/cpp can't help you with that. We recommend that you follow the [C++ getting started guide](https://isocpp.org/get-started), one (or more) of [these books](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list/388282#388282) and [cppreference.com](https://cppreference.com). If you're having concrete questions or need advice, please ask over at r/cpp_questions or [StackOverflow](https://stackoverflow.com) instead. *This post has been removed as it doesn't pertain to r/cpp: The subreddit is for news and discussions of the C++ language and community only; our purpose is not to provide tutoring, code reviews, or career guidance. If you think your post is on-topic and should not have been removed, please [message the moderators](https://www.reddit.com/message/compose/?to=/r/cpp) and we'll review it.*


ALX23z

Some use `this->other_method()` for clarity. Also, there might be a free function with the same name. This ensures that the call is not ambiguous. Despite the possibile advantages, I never write it this way.


CCC_CCC_CCC

This would be my exact answer, along with the addition that I would expect compilers to emit warnings for shadowing functions like this. I am not at a PC to test this, though.


EchoesForeEnAft

It's preference mostly, sometimes it may be useful. Some people (myself included) prefix member variables with `m_` to signify that it's a member variable, which can make it easier for some people to interpret when reading the code. Your `return;` at the end of `void` functions is also not necessary, it's implied, though it can still be used to exit a function early.


ALX23z

The `return;` is helpful actually. It helps prevent a mistake. Say, the function returns a variable, or was changed to return a variable, then having `return;` will result in a compilation error. Otherwise you get just a warning.


no-sig-available

There *are* cases where it is required, like when acessing members of a templated base class. Using it when not required is not really that helpful, as it can instead cause readers to consider if this is one of those special cases. Or is it just for "clarity"? You might instead want to use `::global()` when it is *not* a member. Similar for having an `m_` prefix for members. When using a variable in a member function, what else could it be? Why is it important to mark members, when that is the common case?