Novice C + + when you specify a struct member, you do not know when to use the. operator, and when to use the-I operator.
Conclusion: If the structure identifier is a struct name, use the period operator, or if the identifier is a pointer to a struct, use the arrow operator.
#include <iostream>structinflatable{Charname[ -]; floatvolume; DoublePrice ;};intMain () {using namespacestd; intA; Only to keep the DOS interface inflatable*ps=Newinflatable; cout<<"Enter Name of inflatable item:"; Cin.Get(Ps->name, - ); cout<<"Enter volume in cubic feet:"; CIN>> (*PS). Volume; cout<<"Enter Price: $"; CIN>>ps->Price ; cout<<"Name:"<< (*PS) .name<<Endl; cout<<"Volume:"<<ps->volume<<"Cubic feet\n"; cout<<"Price : $"<<ps->price<<Endl; Delete PS; CIN>>A; To keep the DOS interface onlyreturn 0;}
Output Result:
For example, *PS this structure pointer:
ps->name equivalent to (*ps). Name
"Original" Learn C + + (arrow symbol)---------C + + Primer Plus (6th edition)