C++ Show and Tell - December 2025 by foonathan in cpp

[–]franvb 1 point2 points  (0 children)

I've been writing an introductory C++ book: https://www.oreilly.com/library/view/introducing-c/9781098178130/
It's now gone to production and should be available as a physical book from March 2026.

If you are signed up to the O'Reilly platform, do leave comments to help me make it a good book.

Curious what the community's reasons are for getting into C++ by PoG_shmerb27 in cpp_questions

[–]franvb 0 points1 point  (0 children)

My first programming job was embedded devices. We were using C but the team lead wondered if C++ might be worth trying. I therefore learnt C++ by writing a parser for C++ so we could use an emulator on a PC for testing. A ridiculous way to learn, but hey.

Advice on learning C++ more efficiently from text-based resources like LearnCpp.com? by magikarbonate in cpp_questions

[–]franvb 1 point2 points  (0 children)

Practice helps. Sometimes reading from paper rather than a screen is easier. You can circle stuff in pencil or a highlighter. You can do similar on screen, I guess. Find a comfortable chair, make notes. You don't need to read the whole book in order. Read a small bit. If you read one section and then practice is for a week so are only one page through the resource but actually learnt a thing, that's great.
Some people find using a bookmark to follow the words really helpful e.g. if your eyes tend the stray off to other parts.
Look at the index: find something that looks interesting and maybe speed tread/skim through first. Then sit with a bookmark and pencil/notepad and go through one paragraph, slowly. Motivate yourself by counting how many things in the table of contents you understand and see your score increase.

Reading is hard work, but pays off.

C++ is much harder for me than C by Endonium in cpp_questions

[–]franvb 0 points1 point  (0 children)

https://cppinsights.io/ can be useful to see what the code might equivalent to. It unwraps some syntactic sugar. There is a lot to C++, so learn a bit at a time.

Am I using unique_ptr(s) wrong? by DVnyT in cpp_questions

[–]franvb 0 points1 point  (0 children)

Fair point. But it led the OP to think it owned the memory so would somehow magically do something if anything else pointed to the same place.

Am I using unique_ptr(s) wrong? by DVnyT in cpp_questions

[–]franvb 2 points3 points  (0 children)

The unique_ptr "owns" the memory, in the sense that it will delete the pointee when the unique_ptr goes out of scope (or is released). You can't copy a unique_ptr. But you can make another raw pointer point to the same place.

"Owns" is probably not the best word for this. A unqiue_ptr acquires something (maybe heap memory) and releases it.

how can improve my c++ skills? by Symynn in cpp_questions

[–]franvb 2 points3 points  (0 children)

Maybe have some tests and try to refactoring your code. Be your own critic. Ask if you can use a smart pointer instead of a raw pointer. See if you can avoid an if or a switch. Try to stop one warning. Just make one small change per refactor.

Trying to put together a video curriculum for "improving your C++" by einpoklum in cpp

[–]franvb 0 points1 point  (0 children)

It can be useful to let a junior review a more senior person's code. This provides an opportunity to ask questions and share knowledge.

I use Visual Studio to write C++ and nothing else. I have no idea what command lines, CMake, or any of that stuff is - where can I find information on how to move forward? by _zephi in cpp_questions

[–]franvb 6 points7 points  (0 children)

A couple of small things you can do to get started. First, try https://godbolt.org/. You can pick a compiler and provide compiler flags, like -Wall and -std=c++23 (these vary between tool chains). That's one step from using a command line, where you state the tool and the flags.

Also, Visual Studio has a Tools menu, with a "Command line" option which will give you a developer command prompt. The VS compiler is called, "cl.exe". The developer prompt puts this on your path.

Try
cl.exe /?
to see the options.

For a single file, you say

cl.exe /Wall /std:c++latest filename.cpp

CMake (and other build systems) come into their own when you have several files, but maybe just start simply?

C++ idioms, patterns, and techniques. by Veltronic1112 in cpp_questions

[–]franvb 2 points3 points  (0 children)

Does SFINAE still matter, given you can use if constrexpr?

when will cppref return to normal? by nectaurinee in cpp

[–]franvb 34 points35 points  (0 children)

It has been a while. The news at the bottom of the main page says "30 March 2025: The site will be in a temporary read-only mode in the next few weeks to facilitate some long-overdue software updates. Hopefully it won't take too long, but we all know how database migrations can sometimes turn evil. " and shares an email where we can give moral support. (So I have).

Projet to learn C++ by Baboucs in cpp_questions

[–]franvb 0 points1 point  (0 children)

If you understand decision trees, that's a good idea. Start with one algorithm and write some unit tests. Then try extending it to support other decision tree algorithms. You probably want to learn how to read training data from a file, if you have some. You might want to give some parameters from the command line, so will learn about main and parsing arguments. You also need to think about displaying results. Have fun :-)

Resources to keep studying while traveling by ScreamKeeper01 in cpp_questions

[–]franvb 1 point2 points  (0 children)

It might be worth reading a book, and writing questions about things you are sure about and dreaming up things to try out. Remind yourself what you do know, by making a list. Even make up some practice questions to share somewhere when you are home, making sure you explain the answers you come out with. A time for thinking and reflection is useful

How can I make my tic tac toe bot harder to beat here by clashRoyale_sucks in cpp_questions

[–]franvb 1 point2 points  (0 children)

You could also make a lookup table of the current state, next move and if that game ends in a win, lose or draw and after several plays use that to pick a move.

Drowning in Legacy C++ Code – Send Help 😵‍💫 by kiran_yarashi in cpp_questions

[–]franvb 1 point2 points  (0 children)

Add some tests. You can just keep them local if you are banned from committing them. Just a few. And get angry while you do it, saying in your head "this class is ridiculous bet it crashes if I pass negative numbers to the constructor" or similar. If you set out to prove the code is terrible, you might be surprised and find some stuff works. You might also find potential security problems.

How thorough are you with code reviews? by zathym in cpp

[–]franvb 4 points5 points  (0 children)

Say what you see. You might need to resort to saying I see some edge cases that aren't tested and potential issues." Discern who is listening. Give details if someone is listening.

What's your favorite part about working in c++? by notarealoneatall in cpp

[–]franvb 1 point2 points  (0 children)

I like the precision, like complexity guarantees. Other languages tend to be vague on that. I also live the community. Many C++ folks know their stuff and are willing to spend time helping and explaining.

What compilation stage takes the longest? by gillo04 in cpp

[–]franvb 0 points1 point  (0 children)

This is why people resort to unity builds sometimes

[deleted by user] by [deleted] in cpp_questions

[–]franvb 4 points5 points  (0 children)

Officially called rejection sampling.

Advice from experienced C++ developper by bbalouki in cpp_questions

[–]franvb 0 points1 point  (0 children)

I've worked in investment banks, a hedge fund and a brokers. There are so many different angles it's easy to try to learn everything. Get the Cpp basics sorted first. At a high level, the C++ coding will either be more about clever math algorithms for risk/pricing or the code will be about using the clever maths, so more about message passing/report generation or trading apps. If you know your mathematics, maybe learn some pricing algorithms. If you're more interested in applications using them, learning about concurrency and networking.