I'm practicing using basic objects and classes. I know I'm messing something up with syntax but can't quite figure out what.
#include <iostream>
using namespace std;
class Pizza {
public:
string topping;
int slices;
void GetPizza(string topping, int slices) {
topping = topping;
slices = slices;
}
};
int main() {
Pizza pizza1;
pizza1.GetPizza("cheese", 8);
cout << pizza1.GetPizza;
return 0;
}
I'm trying to print the toppings and number of slices of pizza1. I just keep getting compiler errors. I also wanted to try to print just the topping or just the slice number and couldn't really figure that out either.
EDIT:
v2 of my code with no match for call to errors:
#include <iostream>
using namespace std;
class Pizza {
public:
string topping;
int slices;
void GetPizza(string t, int s) {
topping = t;
slices = s;
}
};
int main() {
Pizza pizza1;
pizza1.topping("cheese");
cout << pizza1.topping("cheese");
return 0;
}