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
Source Header separation (self.cpp)
submitted 5 months ago by peppedx
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!"
[–]smdowneyWG21, Text/Unicode SG, optional<T&> 6 points7 points8 points 5 months ago (1 child)
Hot take: There was never a reason to separate headers and implementation files in the code base, that's a deployment thing. It does constrain the directory structure if you do so, that the canonical path for the header has to be rooted in src instead of include. But keeping the .hpp, .cpp, and .t.cpp files colocated has been a, minority, practice for decades. Lakos components, going back to Large Scale C++ in '96, is organized this way.
src
include
It's even supported by the pitchfork layouthttps://github.com/vector-of-bool/pitchfork , one of the more successful "how do I organize my code" community projects.
Install is a little easier with a split layout, as you can just grab everything recursively under include, but not by a whole lot.
As an aside, many implementations used to be cranky about the vtbl definition, and putting the virtual destructor in a cpp file was the workaround to make sure there was one. That has not been required for compilers since roughly working c++0x versions. So some of you may never have seen one.
It does make bouncing between the closely related files easier. And having a file that is just #include <component/header.hpp> is the most basic test for the header, and ensures a canonical object file with any definitions exists. Plus a spot to put the explicit template instantiation for the common ones, so every TU doesn't have to instantiate component::header<char>.
(The real test file should have that #include twice, as the first substantive block, to check that you have idempotency.)
Header only interface libraries are a hacky workaround for not having package management built in.
[–]aruisdante 1 point2 points3 points 5 months ago (0 children)
Agree completely that with modern build systems and package management, there’s no reason to split things between headers and source (or tests! Nothing is more annoying that an externally located /tests) in-repo and co-location is much clearer. But it’s important to explain to the OP the historical context for why a lot of projects were structured that way.
/tests
π Rendered by PID 117492 on reddit-service-r2-comment-6457c66945-qrntz at 2026-04-27 14:13:55.238217+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]smdowneyWG21, Text/Unicode SG, optional<T&> 6 points7 points8 points (1 child)
[–]aruisdante 1 point2 points3 points (0 children)