A short, clear way to do it with find
is:
find . -regex '.*\.\(cpp\|h\)'
From the man page for -regex
: "This is a match on the whole path, not a search." Hence the need to prefix with .*
to match the beginning of the path ./dir1/dir2/...
before the filename.