Your output complains about a “float division by zero” in line 214. You are only having one division there so you might find pretty fast that class_total[i] is 0 for some i.
My intuition is that labels.size(0) is smaller than 3 and that you initialized class_total to zero for every class before the loop in line 205.
Hope this solves your problem.