TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 230 subscribers
Post #25161 21
When do you decide to introduce classes vs keep free functions in C++?

I’ve noticed a pattern in a lot of C++ codebases where things start out very function-oriented and straightforward, but as soon as the system grows, there’s a strong pull toward introducing classes even when the original logic doesn’t obviously need state.

At the same time, I’ve also seen the opposite problem where people avoid classes entirely and end up with large, tightly connected sets of free functions that become harder to reason about as shared data starts creeping in.

I’m trying to understand how experienced C++ developers actually decide that boundary in practice. Is it usually driven by ownership and state modeling first, or is it more about managing complexity as it appears over time?

https://redd.it/1t8b6h2
@r_cpp
Reddit From the cpp community on Reddit Explore this post and more from the cpp community
More from @r_cpp
  1. Oct 3, 2026Teodorescu - [https://youtu.be/vVFFW6hoG1Y](https://youtu.be/vVFFW6hoG1Y) * Demystifying C…
  2. Oct 3, 2026New C++ Conference Videos Released This Month - September 2026 (Updated To Include Videos…
  3. Oct 3, 2026HPX 2.0.0 RC1 Released! – The HPX Project HPX is a general-purpose parallel C++ runtime sy…
  4. Oct 3, 2026[PLDI'26] Persistent Iterators with Value Semantics https://www.youtube.com/watch?v=cq33C5…
  5. Oct 3, 2026A Cross-Toolkit Timeline Control, Wed, Oct 14, 2026, 6:00 PM https://www.meetup.com/utah-c…
  6. Oct 3, 2026Upcoming C++ User Group meetings in October https://meetingcpp.com/meetingcpp/news/items/U…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →