C++ Expression must have pointer-to-object type

You probably meant:

c_info[i].hoursWorked;

since c_info is an array, by doing c_info[i] you’ll access the i-th instance (object) of Employee class in c_info array, and then obtain hoursWorked through . operator.

Now you can clearly see that your variant simply doesn’t make sense, as hoursWorked is just an integral type and not an array, and therefore you cannot apply [] operator to it.

Leave a Comment