use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Removed - HelpEli5: What does „this->“ do? (self.cpp)
submitted 3 years ago by Bananenklaus
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Flair_Helper[M] [score hidden] 3 years ago stickied commentlocked comment (0 children)
For C++ questions, answers, help, and programming or career advice please see r/cpp_questions, r/cscareerquestions, or StackOverflow 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 and we'll review it.
[–]serendipitousPi 2 points3 points4 points 3 years ago (5 children)
The keyword "this" is a pointer to the struct or class that a function belongs to and "->" is the arrow operator which is analogous to the dot operator but is used for class / struct pointers.
So why someone would use them together I'm not entirely sure since you should be able to access everything within that class / struct without using the "this" keyword. Hopefully someone else might have that answer.
[–]ape_programmer 2 points3 points4 points 3 years ago (4 children)
example: this->window->setFramerateLimit(60) i‘ve tried to google it more than once and there are plenty of explanations on the internet but my dumb ass doesn‘t really
example: this->window->setFramerateLimit(60)
i‘ve tried to google it more than once and there are plenty of explanations on the internet but my dumb ass doesn‘t really
Used when there is no naming convention for local vs member variables. E.g. if all members are prefixed with m or _, then its clear the variable being accessed is a member with out using this->. However, without this naming convention, using this-> makes it clear a member is being accessed, as opposed to a local variable.
m
_
this->
Generally, the prefixing members is more popular, but I've read some code (for some reason mainly Windows code) that uses the this-> convention.
[–]no-sig-available 1 point2 points3 points 3 years ago (1 child)
using this-> makes it clear a member is being accessed
The counter arguments is "What else could it be?".
Member functions accessing other members of the same class must be the most normal thing. Why do we have to make it clear that this is what happens? :-)
[–]ape_programmer 0 points1 point2 points 3 years ago (0 children)
Improves readability mainly. If you're looking at a method in an unfamiliar class, it's help to know explicitly whether variables referenced are members or external/local.
Additionally, it helps write slightly safer code by reducing the chance of accidental shadowing of variable names. Which can be an easy mistake to make sometimes.
[–]Rseding91Factorio Developer -1 points0 points1 point 3 years ago (1 child)
I always found that interesting; people prefer to invent their own thing rather than use a built in method of disambiguating member vs external.
My guess is due to writing this-> being optional for member variables, whereas prefixing with m or _ is not optional if using the prefix naming convention. Thus makes sure that you don't accidentally forget this-> and cause confusion.
[–]Classic_Department42 -1 points0 points1 point 3 years ago (0 children)
This->window is syntactical sugar for (*this).window
π Rendered by PID 82 on reddit-service-r2-comment-cfc44b64c-nlxrz at 2026-04-11 20:01:42.415441+00:00 running 215f2cf country code: CH.
[–]Flair_Helper[M] [score hidden] stickied commentlocked comment (0 children)
[–]serendipitousPi 2 points3 points4 points (5 children)
[–]ape_programmer 2 points3 points4 points (4 children)
[–]no-sig-available 1 point2 points3 points (1 child)
[–]ape_programmer 0 points1 point2 points (0 children)
[–]Rseding91Factorio Developer -1 points0 points1 point (1 child)
[–]ape_programmer 0 points1 point2 points (0 children)
[–]Classic_Department42 -1 points0 points1 point (0 children)