could not deduce template argument for

Upon compilation VC++08 Express launches a ton of errors about some kind of templates not being able to be deduced.

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
//default values in functions
#include <iostream>
#include <string>
using namespace std;

int divide (int a, int b=2)
{
	int r;
	r=a/b;
	return (r);
}

int main()
{
	string cmd;
	cout << divide(12);
	cout << endl;
	cout << divide(20, 4);
	cout << endl;
	do
	{
	cout << "> ";
	getline(cin, cmd);
	}while(cmd != 'q');
	return 0;
}


Last edited on
All I can see is that on line 24, ('q') should be ("q"). If that's not it, you should post the error messages.
Hm, you were right.

I thought that you must put single quotes for single characters, and double quotes for constant strings.

Thanks.
You are correct, but you are comparing "q" to an std::string, not a char, so you must use double quotes.
Topic archived. No new replies allowed.