I created a struct and void function. I want to write out age and name inside of struct xyz with the void abc. But i didn't understand i'm getting an error on case 1-2 part
type name isn't allowed
#include <iostream>
using namespace std;
struct xyz {
int age = 20;
string name = "name";
};
void abc() {
int num;
cin >> num;
switch (num) {
case 1: cout << xyz.age << endl;
return;
case 2: cout << xyz.name << endl;
return;
}
}
int main()
{
for(;;)
abc();
}