Hello, and welcome to the 47th tutorial in the c++ programming series, and in this part we're gonna be looking at class access. Basically, there are three keywords that can be used to specify the access scope of variables and methods or class. And these are public private, protected. public members are accessible from anywhere where the object it will also enjoy it. And so probably members of a class are accessible only from within other members of the same class or from their friends, basically, friends is something that we'll cover later on in this series. And protected members Finally, are accessible from other members of the same class very similar to private or from the friend role, but also from members from their derived classes.
Derived classes is something that we're also going to be covering later on the series. So for the purpose of this tutorial, we'll just be covering public and private. Okay, so let's just go ahead and open up our project. Just a quick thank you almost a 1500 subscribers want to thank everyone that's watched us everyone that subscribed and just thank you to the community so let's go ahead with this tutorial man take credit class and he normally would you type in the name your Catherine according vehicle Gracie with a semicolon at the end and then was not a public int speed low age kroy x ration and now we're going to just create a public function called print function or method is create an object of this function battling for grace I'm just going to implement the function itself so with void vehicle print function in the STDs for the CEO we have to do X seven acceleration annoying someone just set acceleration as well, but acceleration equals nine nine that's fine.
I can click on the nine twice but it's a okay. So we just declare our objects and simply interview and train you to be just be the call 900 Toyota da speed equals 18 912 and STD c out Toyota dot speed stt occurred on this one They really got to know. And then if we just run this, it prints out 89. But if we were to try and change speed to acceleration, you can see, in Xcode, there's a red line program. This basically means that you can't access it. outside of the scope, aka is private, which can only be accessed within the class itself.
So if you try to run this to the aerobic acceleration in the private memory of Reaper, aka, we can't access it. But obviously, you got another way of printing the end and also setting at the same time, which is Toyota dot print function, if we run that, we get 9900. So that's the this is just a quick overview of the scope of variables and methods. So you'll see the keyword public, private or protected. And then below that, you just put in your variables and methods, and they will be within the scope. So that's it for this part in the next part.
We'll be looking at class constructors. If you have any questions feel free to message us as well as some systems that create the email will be in the description you can comment on the video is directing messages via YouTube, or the require link for source code will also be in the description. And as usual, thanks for watching and I hope you have a nice day.