invalid-conversion-from-const-char-to-char

Pages: 12
Apr 1, 2013 at 4:11pm
I would really like to say a massive thank-you to anybody who has helped me through this problem. I will be studying your code Zereo as it opens my eyes to new coding practices, it is so amazing that you and everyone else have given this issue so much time.

Really appreciated =]
Apr 1, 2013 at 4:28pm
L B wrote:
@Cubbi boy I would love to use that standard of C, but times have changed.

What do you use, Turbo C? It really bafffles me when people consider a 14 year old, obsolete language standard as something novel... Come to think of it, I'll make a thread in Lounge.
Apr 1, 2013 at 4:33pm
@Cubbi did you not seem my IDEOne link? (will move discussion to that thread)
Apr 1, 2013 at 5:28pm
My five cents.

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
#include <iostream>
#include <functional>

int main()
{
	while ( true )
	{
		enum : size_t { PLUS = 1, MINUS, MULTIPLY, DIVIDE, OP_NUMBER = DIVIDE };

		std::cout << "Would You Like To\n\n";
		std::cout << "Add...........1\n";
		std::cout << "Substract.....2\n";
		std::cout << "Multiply......3\n";
		std::cout << "Divide........4\n";
		std::cout << "Or exit?......0\n";

		std::cout << "\nEnter your choice: ";

		size_t choice = 0;
		std::cin >> choice;

		if ( !choice ) break;

		int x, y;

		if ( choice <= OP_NUMBER )
		{
			std::cout << "\nEnter two numbers: ";
			std::cin >> x >> y;
		}

		switch( choice )
		{
		case ADD:
			std::cout << x << " + " << y << " = " << std::plus<int>()( x, y ) << std::endl;
			break;
		case SUBSTRACT:
			std::cout << x << " - " << y << " = " 
				<< std::minus<int>()( x, y ) << std::endl;
			break;
		case MULTIPLY:
			std::cout << x << " * " << y << " = " 
				<< std::multiplies<int>()( x, y ) << std::endl;
			break;
		case DIVIDE:
			std::cout << x << " / " << y << " = " 
				<< std::divides<int>()( x, y ) << std::endl;
			break;
		default:
			std::cout << "Error! Invalid choice. Please, try again." << std::endl;
			break;
		}

		std::cout << std::endl;
	}

	return 0;
}
Last edited on Apr 2, 2013 at 9:21pm
Apr 2, 2013 at 4:05pm
I'd like to point out that if to use an array of std::function then my code would be even more simply that is the switch statement could be removed.:)
Topic archived. No new replies allowed.
Pages: 12