The wc command with option -l prints the line count of each file and a total if multiple files are given as input.
Say I have two files foo.cpp and bar.h with 10 lines each, then wc -l gives this result:
$ wc -l *.cpp *.h
If you only need the total value, you could cat the files and pipe the result to wc -l:
$ cat *.cpp *.h | ...