Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- struct person //The members in the struct.
- {
- string name;
- string lastname;
- int age;
- int weight;
- float height;
- };
- person struct1 = //Give value to the members and give object name.
- {
- "Felix",
- "Nilsson",
- 14,
- 65,
- 163.5
- };
- int main()
- {
- cout << struct1.name << endl;
- }
- /*Why not use an array instead? One array can only store one type of datatype but a struct can store all datatypes in one block.*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement