Why isn't this class compiling?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <cstdlib>
#include <vector>
#include <iostream>
using namespace std;


class SpeedRadar
{
	public:
		double averageSpeed(int minLimit, int maxLimit, vector<int> readings){
			double threshold = readings.size()/10;
			double illegals = 0;
			double average = 0;
			for(vector<int>::iterator it = readings.begin(); it != readings.end(); it++){
				if( (*it < minLimit) || (*it > maxLimit)){
					illegals += 1;
				} else {
					average += *it;
				}
			}
			
			average /= readings.size()-illegals;
			if(illegals > threshold){
				return 0.0;
			} else {
				return average;
			}
		}
		
}


This is for a beginner level problem at TopCoder.com.
    
A speed radar is installed in a highway zone where the maximum speed limit is maxLimit mph, and the minimum speed limit is minLimit mph. Any reading that is strictly above or below this interval is an infringement.
Periodically, the radar readings are analyzed to make sure that the sensors are working properly. It is assumed that most drivers obey speed limits, and therefore, the radar will be considered faulty if more than 10% of its readings are infringements.
Given the radar readings over a period of time, return the average speed of all cars that are driving within the speed limits. If the radar is faulty, return 0.0.





This is the compiling error it gives me when trying with their portal:

Your code did not compile:

errors compiling:

end of your submission:10030: error: multiple types in one declaration


It might be something minor but if anyone can offer some insight, I'd be very appreciative.
The semicolon on line 30 is AWOL. You may want to add one there.

-Albatross
Last edited on
Awesome, thank you! Im still getting used to classes and how their structure deviates from functions. Thank you very much!
Topic archived. No new replies allowed.