If you want the average of the whole class, you don't want the average of the average of the girls and boys, which would be 180+165/2=172.5
What you want to do is take 180 x 12 (to get the heights of all the boys added together) plus 165 x 18 (to get the heights of the girls, then added to the heights of the boys) then divide by the total number of people in the class (30).
Attention: NOTHING on this site may be reproduced in any fashion whatsoever without explicit consent (in writing) of the owner of said material, unless otherwise stated on the page where the content originated. Search engines are free to index and cache our content. Users who post their account names or personal information in their questions have no expectation of privacy beyond that point for anything they disclose. Questions are otherwise considered anonymous to the general public.