"no match for operator<" and "no match for operator>"

string Amount;

1
2
3
4
if (Amount > 5 && Amount < 1)
{
    //Rest of the code is here
}

For some reason the operators > and < wont work.
Why should they? Your comparing a string to a constant integer. Convert Amount to an int then compare.
When I do that and try to execute the program it says this.
"This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information."
How are you converting it? A common way is
1
2
3
4
std::stringstream ss(std::string("77"));
	int x = 0;
	ss>>x;
	std::cout<<x;
I'll just post the whole code, Amount is determining the amount of items to purchase.
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()
{
    string Input;
    string Aisle;
    string Section;
    string Item;
    string Type;
    string none = 0;
    string Space1;
    string Space2;
    string Space3;
    string Space4;
    string Space5;
    string Space6;
    string Space7;
    string Space8;
    int Amount;
    int MaltoMeal = 5;
    int Oatmeal = 2;
    int CreamofWheat = 3;

    cout << "Welcome to the Shop n' Go cornerstore!" << endl;
    cout << "To browse our wares type 'StartShopping'." << endl;
    cin >> Input;
    if (Input == "StartShopping")
    {
        cout << "\nAisle 1: Hot Cereal\n         Cold Cereal\n         Jarred items" << endl;
        cin >> Aisle;
        if (Aisle == "Aisle1")
        {
            cout << "\nOn this aisle we have: HotCereal, ColdCereal, and Jarreditems." << endl;
            cout << "You walk down Aisle 1 and stare at our wares." << endl;
            cout << "Choose your section to look at." << endl;
            cin >> Section;
            if (Section == "HotCereal")
            {
                cout << "\nWe currently have: " << MaltoMeal << " boxes of MaltoMeal, " << Oatmeal << " boxes of Oatmeal, and " << CreamofWheat << " boxes of CreamofWheat." << endl;
                cout << "\nTo purchase one of these items type AddToCart or type NewAisle to find a new aisle to look on and NewSection to look at different sections of the Aisle." << endl;
                cin >> Type;
                if (Type == "AddToCart")
                {
                    cout << "\nWould you like to add MaltoMeal, Oatmeal, or CreamofWheat." << endl;
                    cin >> Item;
                    if (Item == "MaltoMeal")
                    {
                        cout << "\nHow much would you like to purchase?" << endl;
                        cin >> Amount;
                        if (Amount > 5 && Amount < 1)
                        {
                            cout << "Sorry, we do not have that much MaltoMeal at the time." << endl;
                        }
                        else
                        {
                            cout << "\nAdding " << Amount << " boxes of MaltoMeal to your cart. . ." << endl;
                            if (Space1 == none)
                            {
                                Space1 == Item;
                            }
                            if (Space2 == none)
                            {
                                Space2 == Item;
                            }
                            if (Space3 == none)
                            {
                                Space3 == Item;
                            }
                            if (Space4 == none)
                            {
                                Space4 == Item;
                            }
                            if (Space5 == none)
                            {
                                Space5 == Item;
                            }
                            if (Space6 == none)
                            {
                                Space6 == Item;
                            }
                            if (Space7 == none)
                            {
                                Space7 == Item;
                            }
                            if (Space8 == none)
                            {
                                Space8 == Item;
                            }
                        }
                    }
                    if (Item == "Oatmeal")
                    {
                        cout << "\nHow much would you like to purchase?" << endl;
                        cin >> Amount;
                        if (Amount > 2 && Amount < 1)
                        {
                            cout << "Sorry, we do not have that much Oatmeal at the time." << endl;
                        }
                        else
                        {
                            cout << "\nAdding " << Amount << " boxes of Oatmeal to your cart. . ." << endl;
                            if (Space1 == none)
                            {
                                Space1 == Item;
                            }
                            if (Space2 == none)
                            {
                                Space2 == Item;
                            }
                            if (Space3 == none)
                            {
                                Space3 == Item;
                            }
                            if (Space4 == none)
                            {
                                Space4 == Item;
                            }
                            if (Space5 == none)
                            {
                                Space5 == Item;
                            }
                            if (Space6 == none)
                            {
                                Space6 == Item;
                            }
                            if (Space7 == none)
                            {
                                Space7 == Item;
                            }
                            if (Space8 == none)
                            {
                                Space8 == Item;
                            }
                        }
                    }
                }
            }
        }
    }
    ofstream Cart;
    Cart.open ("Cart.txt");
    Cart << "\n" << Space1 << "\n" << Space2 << "\n" << Space3 << "\n" << Space4 << "\n" << Space5 << "\n" << Space6 << "\n" << Space7 << "\n" << Space8 << endl;
    Cart.close();
    return 0;
}
string none = 0;
Thank you lol, I was thinking using
 
string none = 0;

would classify as 'none'. FAIL
btw, what's this use for?

 
Space1 == Item;


and the other similar codes?
Topic archived. No new replies allowed.