Following this answer, when I type (modify-syntax-entry ?_ "w")
and do M-x eval-region, it has the effect I'm looking for, albeit only for that buffer. I've put (modify-syntax-entry ?_ "w") in my .emacs file, however and after restarting, it's not having effect in my C/C++ code.
I'm using Emacs GNU Emacs 26.3 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.24.13) of 2019-12-11. My OS is: Fedora release 31 (Thirty One).
There are questions with nearly the exact same title, but their accepted answers do not work for C/C++ mode, so this is a different question.