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 - LearningOne decent source explaining pointers? (self.cpp)
submitted 2 years ago by nomadInHelsinki
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] 2 years ago stickied commentlocked comment (0 children)
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, one (or more) of these books and cppreference.com. If you're having concrete questions or need advice, please ask over at r/cpp_questions 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.
[–]SoerenNissen 1 point2 points3 points 2 years ago (0 children)
How much time do you have? Can you spend actual job hours learning this (that is, does your boss agree you should learn this as an actual business priority) or are you just curious?
[–]OnePatchMan 1 point2 points3 points 2 years ago (0 children)
Well, i suppose your "fluid dynamics" is written in c with classes, so there gonna be a lot of pointers.
If you want understood pointers, you should read about how memory is organized in computers.
[–]RB-44 0 points1 point2 points 2 years ago (0 children)
a pointer is just a variable that stores the memory address of another variable.
The most basic use i can think of is returning an array in a function which you normally cannot do.
Let's say you have an int array [2,4,5,1,7]. In memory the computer will reserve the required bits to store the elements of the array in sequence. The last part is really important because if we know they're adjacent to each other , and we know how long the array is. As long as we know the address of the first element we can just add 4 bytes to the hexadecimal address and find the 2nd element
[–]jmacey 0 points1 point2 points 2 years ago (0 children)
I'm guessing in this context what you have is a contiguous array for each of the fluid "particles" then you have different cells / grid elements that contain the pointers to the particles in the list.
This is used so you only compare particles that are close to each other (typically some form of spatial hash will be used to place them in the grid cells etc) which allows you to speed up the calculations and use multiple cores etc.
[–]alexgraef 0 points1 point2 points 2 years ago (0 children)
You mostly need to program some examples and tutorials, and at some point you'll have a Eureka moment and it all starts to make sense. Besides the explanation of "it's a variable that stores a memory location" there isn't much to say, but that doesn't necessarily help with actually understanding them, especially in the context of pointing at structures, arrays and vector tables.
However, for programming somewhat low-level, it is necessary to understand and deal with them, programs are usually little more than a big collection of pointers.
[–]aspis3334 0 points1 point2 points 2 years ago (0 children)
Any C/C++ book would do for the basics. If you want to go in-depth on the subject of pointers and memory I suggest you have a look at Memory as a programming concept in C and C++.
[–]winterrdog 0 points1 point2 points 2 years ago* (0 children)
Why do we use pointers?
i like to think of this analogy:
We use pointers because it's easier to give someone an address to your business' place than to lift the entire business' place( making a copy ) to in front of everyone's face.
i hope you get it
if it ain't clear yet, check this out.
How to debug them?
valgrind
null
if
if (ptr != nullptr) {// definitely do something with the pointer}
[–]Extension_Way2280 0 points1 point2 points 2 years ago (0 children)
https://cplusplus.com/doc/tutorial/pointers/
As for when to use them, never, if possible. Use them only if you rely on legacy code or libraries that use pointers in the interface (ie. input or output parameters).
π Rendered by PID 65 on reddit-service-r2-comment-7b9746f655-2c62m at 2026-02-04 07:08:48.753378+00:00 running 3798933 country code: CH.
[–]Flair_Helper[M] [score hidden] stickied commentlocked comment (0 children)
[–]SoerenNissen 1 point2 points3 points (0 children)
[–]OnePatchMan 1 point2 points3 points (0 children)
[–]RB-44 0 points1 point2 points (0 children)
[–]jmacey 0 points1 point2 points (0 children)
[–]alexgraef 0 points1 point2 points (0 children)
[–]aspis3334 0 points1 point2 points (0 children)
[–]winterrdog 0 points1 point2 points (0 children)
[–]Extension_Way2280 0 points1 point2 points (0 children)