我可以使用指针解决问题。目的是打印出一些东西
struct Nerd
{
int zitnuml;
int sc_hours;
};
int main()
{
Nerd luis;
Nerd *ptr = &luis;
ptr->sc_hours = 100;
ptr->zitnuml = 5;
cout << luis.sc_hours << endl;
cout << luis.zitnuml << endl;
}
///Why write the above if I can just do this instead:
int main()
{
Nerd luis;
luis.sc_hours=100;
luis.zitnuml=5;
cout << luis.sc_hours << endl;
cout << luis.zitnuml << endl;
}
两个主函数都打印相同的东西,所以为什么要使用指针?