Hello, welcome to the 49th tutorial on the c++ program series and in this problem we are looking at class pointers. Similar to variables. objects can also point to over objects. local node member pointers can be accessed using the dash and greater than symbol. But we'll show you that in a moment of how to access member of objects. I mean member the pointer should say don't open up the CPP on open up the project itself.
We can leave that behind to the minor Okay, so what we want to do is just quickly create a class class vehicle. And in here we're gonna create some public's stuff. vehicle to the critical construct tests been variable flow Ah, what we're gonna do is have an overloaded constructor as well. Which is which will simply take speed 10 look at age temp analysis implement the constructors of vehicle vehicle, vehicle colon colon vehicle. And here we will just set the speed to 60 by default and the age to 141. And then do vehicle Conan Conan vehicle, implement the overloaded constructor and a quick way to get the prompts to do is copy and paste them.
No general programming to copy and paste as much as you can. We'll just do stuff like that, that will choose your load good That way, it's less work for you to do. And eventually it does build up equals speed temp. Again, that is totally up to you how you want to do it, that's a no recommendation from us. So what we're going to do is remove this and create a vehicle object called BMW, pass it through values 500 783 and do vehicle and now we're going to create a pointer object, our vehicles are going to asterik called a P and the B two equals to memory address of BMW, semi colon, maybe do BMW too. So to access the members of BMW, sorry, it should be convenient to access the members of BMW you do dash greater than that's how you access the members have a pointer for the function and the variables.
That was when the speed equals 467 Now if we were to do STDs ww STD line XML, we're going to also copy and paste these before that we run this we'll get a value of 500 and 467 value 500 is initialized with the value of 100. And because BMW two just points to be in the B's, anything that we do to be in the YouTube will affect BMW, the speed of BMW and therefore six seven but if we were to just put in a v two here and run this value of 467 as well because it just points to it. So that's it for this tutorial. If you have any questions feel free to message us support us on our systems that Cody k the email will be in the description. You can comment in this video or just directly messaged us via YouTube as well.
All the recording for source code will also be in the description. The next part of the series we'll be looking at overload Do operators and as usual, thanks for watching and I hope you have a nice day.