pow ambiguous call to overloaded function

The purpose of the program is to remove a specific substring from the string, but for some reason it gives me an error when using pow. I don't how I used the function incorrectly, even if it's not the first time I use it. Why doesn't it work?

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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;   

void classifyNumber (int, int &, int &);

int main ()
{
	bool done;
	char k;                           
	int odds;
	int evens;
	int length;
	int num;

	done=false;
	evens=0;
	odds=0;	
		
	cout<<"Enter the number of digits you wish to enter: ";
	
	while (!done)
	{
		cin>>length;

		if (length<=0)
		{
			cout<<"Invalid entry! Please try again";
			cout<<"\n";
		}
		else
		{
			done=true;
		}
	}
	done=false;
	cout<<"\n";

	cout <<"Please enter a postive integer: ";

	cin>>num;

	classifyNumber (num , evens, odds);
	
	cout<<"Enter any character to continue...";
	cin>>k;

	return 0;
}

void classifyNumber (int number, int &evens, int &odds)
{
	int num;
	int a;
	int b;
	int length;

	for (int i=length;i>=0;i--)
	{
		int c;
		c=length-i-1;
		
		num=number/(pow(10,c));
		b=(num/10)*10;
		a=num-b;

		if (a==1 || a==3 || a==5 || a==7 || a==9)
		{
			odds++;
		}
		if (a==2 || a==4 ||a==6 || a==8)
		{
			evens++;
		}
	}
	cout<<"There are "<<odds<<" odd and "<<evens<<" even digits";
}
Last edited on
Topic archived. No new replies allowed.