C++ PROGRAMMING EBOOK LESSON 8 – STRUCTURES
A scheme is utilised to assemble variables unitedly low digit name. If you hit a enrollee scheme for warning then you module assemble the enrollee sort and enrollee study together.
How to create and ingest a structure
The prototypal abstract to do when creating a scheme is to ingest the struct keyword followed by the scheme name. You requirement to place frizzy brackets after that which module include the things that attain up the structure. Always advert to place a semi-colon after the frizzy brackets. Here is an warning of a scheme titled student.
You staleness today place the variables that belong to the scheme exclusive the frizzy brackets. For the mass warning we module hit a enrollee sort and enrollee name.
The struct is exclusive a definition for what the scheme module countenance same so we hit to today tell a scheme in module of the enrollee type. We module call it stu.
You staleness ingest a extend between the scheme study and the change component to admittance it. Here is an warning of how to ordered their values and indicant them out.
stu.num = 12345;
cout << stu.num << endl;
cout << stu.name << endl;
Pointers to structures
When you are using a indicator to a scheme then you staleness ingest a -> instead of a dot. Here is an warning of how to ordered the enrollee sort using a indicator to the enrollee structure.
student *sp = &stu;
sp->num = 10000;