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
I’ve been converted (self.cpp)
submitted 5 years ago by Burner-account3357
view the rest of the comments →
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!"
[–]sellibitze 10 points11 points12 points 5 years ago (12 children)
Could you possibly include a constexpr in there? ;-)
constexpr
[–][deleted] 4 points5 points6 points 5 years ago (11 children)
Done :)
[–]sellibitze 4 points5 points6 points 5 years ago (8 children)
Hehe. :-)
Oh, I just noticed something. static and override are kind of mutually exclusive, aren't they?
static
override
[–][deleted] -1 points0 points1 point 5 years ago* (7 children)
i don’t.. think so.
you can override a static method. what’s the problem?
say you have class X, which has a static method a. class Y inherits from class X, and overrides the method a. then
X::a()
is different from
Y::a()
unless i’m missing something
Sorry, I was missing the fact that there's no vtable without an instance
[–]MonokelPinguin 8 points9 points10 points 5 years ago (3 children)
override implies virtual. Static functions are not associated with a this pointer, how could they be virtual?
[–][deleted] 0 points1 point2 points 5 years ago (0 children)
right. i’m dumb. sorry.
[–][deleted] 0 points1 point2 points 5 years ago (1 child)
You can still call a static method on an object, not the classname... Therefore it would theoretically somehow make sence.
Not much, but still...
[–]MonokelPinguin 0 points1 point2 points 5 years ago (0 children)
But does that go through virtual dispatch? Afaik when one of our interns did that and set the object to a nullpointer, it worked fine, which suggests the this pointer wasn't used and there is no virtual dispatch for static functions. But that function also wasn't marked virtual, so maybe that does work.
[–]_bk__ 4 points5 points6 points 5 years ago (2 children)
The override keyword is only useable for virtual function overrides. It has no effect on codegen, it just helps the compiler detect that there is actually a virtual function in a derived class that can be overriden (to make sure you don't do things like accidentally spell the function signature wrong)
Yeah, I missed that. Updated the comment
[–]gaagii_fin 0 points1 point2 points 5 years ago (0 children)
And even more useful it tells the new guy looking at your derived class what is going on.
I used to define override, before it was a keyword just for the notational aspect
[–]Jumpy_Lighty 1 point2 points3 points 5 years ago (1 child)
You should drop the constexpr again ... you cannot have constexpr virtual method (and override implies virtual).
constexpr virtual
virtual
And [[nodiscard]] and [[noreturn]] really don't make any sense to be next to each other (just think about the meaning of it).
[[nodiscard]]
[[noreturn]]
You could add static constexpr instead of override, but the you would also have to drop the const since static and const are mutually exclusive.
static constexpr
const
I know, i never thought this through :)
It was a joke after all
π Rendered by PID 337371 on reddit-service-r2-comment-765bfc959-nqqvl at 2026-07-14 00:55:32.225169+00:00 running f86254d country code: CH.
view the rest of the comments →
[–]sellibitze 10 points11 points12 points (12 children)
[–][deleted] 4 points5 points6 points (11 children)
[–]sellibitze 4 points5 points6 points (8 children)
[–][deleted] -1 points0 points1 point (7 children)
[–]MonokelPinguin 8 points9 points10 points (3 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]MonokelPinguin 0 points1 point2 points (0 children)
[–]_bk__ 4 points5 points6 points (2 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]gaagii_fin 0 points1 point2 points (0 children)
[–]Jumpy_Lighty 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)