Here are couple more simple functions, used for commenting out a block of C++ code.

c++-comment-line
below simple inserts "//" at the start of a line

c++-comment region will take the current region and run the c++comment-line on each line.


(defun c++-comment-region()
"Comment a region out"
(interactive)
(save-excursion
(save-restriction
(narrow-to-region (point) (mark))
(goto-char (point-min))
(while (> (point-max) (point))
(c++-comment-line)
(forward-line)))))

(defun c++-comment-line()
"Comment a line of C++ out"
(beginning-of-line)
(insert "//"))