Error expression must have integral or enum type

My following code gave error message like expression must have integral or enum type when I tried to add or subtract two floating point numbers. Error message comes from the line float add=mean+sd; and float minus=mean-sd;

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 vector<float>histogram_remove_noise(vector<float>histogram)
{
	for(int i=0;i<histogram.size();i++)
	{
		cout<<histogram[i];
	}
	cout<<endl;

	float sum = accumulate( histogram.begin(), histogram.end(), 0.0f );
	float avg=sum/histogram.size();
	
	cout<<sum <<avg<<endl;

	float temp = 0;
	float variance;
 
    for(int i = 0; i < histogram.size(); i++)
         temp += (histogram[i] - avg) * (histogram[i] - avg) ;
 
    variance =temp / histogram.size();

	cout<<variance<<endl;

	float sd=sqrt(variance);

	cout<<sd<<endl;

	
	
	float add=mean+sd;
	float minus=mean-sd;

	for(int i = 0; i < histogram.size(); i++)
	{
		if((histogram[i]>(add))||(histogram[i]<(minus)))
			histogram[i]=0.0;
	}

	for(int i=0;i<histogram.size();i++)
	{
		cout<<histogram[i];
	}
	cout<<endl;


	int test;
	cin>>test;

	return histogram;

}
The variable mean does not exist within histogram_remove_noise(...). You need to create and initialize this variable.
Thank you. Now it works..
Topic archived. No new replies allowed.