Hello, welcome to the 42nd tutorial in c++ programming series. And in this problem we're looking at structs. structs, also referred to as structure by some developers are a way of grouping data, data, variables and methods. Usually the data grouped together all connected in some form. For example, address book may have a struct which has user details, so maybe their contact name, their contact, address, phone number, etc. And he might have a method other than a phone, this person so you will have now on a mobile device, let's show you how to implement a really simple struct within c++.
Later on, we're going to be looking at classes structs are very similar to classes or classes are a new thing in c++ only compared to see obviously, it's in other languages as well, but that's what makes this language oriented. So let's just put in house for struct, see the keyword struct name name is gonna call and you put curly braces. And then after that you put, ignore that. After they put a semicolon and Navy. Well you just put your variables and methods and put in the age. The we'll get rid of that.
And just bear with me a second is annoying. Okay, put a semi coat on there. Then we're going to create an alert because speed is creating variable in a normal fashion analysis quick function. So we need a function. And then here we're simply going to see that if I just say the point Command Line networking use the struct, what you do is actually create a struct objects eating an empty struct car. Name the name of your object variables.
So simple BMW toy you turn semicolon on them in this access it's variable commercials but BMW dot dot speed changes to 900. Now we can just do STD CEO in the meters speed TV and line. Everyone this is going to open up the debug window. Now a protect 900 even though isn't really set to 100. So if we just come in at the floor in a second, it prints out 130 originally set to 100. We're also going to do is be able to view dot print function semicolon if we run this We get 100 and preclude access to method B and B.
We're going to be doing anything with Toyota but you can't study a you can see the same night Ed which group common data properties together. That's it for this tutorial on strux. If you have any question, feel free to message us at support at solar systems calm Okay, the email will be in the description. You can comment on this video or just directly message us via YouTube. In the next part of this series, we'll be looking at type aliases, or the requiring for source code will also be in the description. And as usual, thanks for watching and I hope you have a nice day.