> someone suggested that I might be using the wrong command to build the program and, instead of cpp, I should use g++ (Gnu C++ compiler).
I suspect the OP was using GCC to compile the C++ code so not the wrong build command the wrong compiler.
GCC is the GNU C Compiler and g++ is the GNU C++ compiler, two totally compilers for two totally different languages.
I see this as nothing more than an example of how well modern day IDEs hide the command line from the developer, so much so that when they actually try to do something from the command line it feels like a foreign and strange place.
Why not come up with some in-file indexing system (i.e. define a Keywords or Topic section using a unique text pattern) and then configure ctags so that it can scan a given file for that information.
You could then just run ctags from inside Vim to give you a full index.