Beim Lernen von C++ - Klassen - Grundlegende Vererbung - hat mein Programm einen Fehler zurückgegeben, der besagt: "C++ verbietet den Vergleich zwischen Zeiger und Ganzzahl und C++ verbietet den Vergleich zwischen Zeiger und Ganzzahl". Was habe ich falsch gemacht? Danke für Ihre Hilfe! :-)C++ - Basisvererbung
#include <iostream>
using namespace std;
class Pizza
{ public: int slices; char topping[10]; bool pepperoni , cheese ; };
int main() {
// Make your own Pizza!
Pizza pizza;
cout << "\n You can have Cheese or Pepperoni Pizza!";
cout << "\n Type [cheese] or [pepperoni] \n";
cin >> pizza.topping[10];
if (pizza.topping[10] == "pepperoni") { pizza.pepperoni = true;}
if (pizza.pepperoni == true) {cout << "How many slices of pepperoni would you like?";};
if (pizza.topping[10] == "cheese") { pizza.cheese = true;}
if (pizza.cheese == true) {cout << "How many slices of cheese would you like?";};
cin >> pizza.slices;
if (pizza.slices >= 1) {cout << "You ordered " << pizza.slices << " slices of " << pizza.topping[10] << " Pizza!"; }
else if (pizza.slices <= 0) {cout << "Change your mind?"; }
else { cout <<"Can't Decide? That's Okay.";}
}
Es würde helfen, wenn Sie Ihren Code ein wenig besser formatiert. – PaulMcKenzie
Wo ist die Erbschaft? – juanchopanza
'cin >> pizza.topping [10];' - Was hast du damit erwartet? Sie haben 'std :: string' nicht in dem, was Sie gelernt haben, behandelt? – PaulMcKenzie