I might do it that way instead of doing get buffer I might just copy this declaration pop it in here name it a friend like so and what that means is that I'll actually be able to write code such as this so you can see I'm accessing a private member if this code wasn't present here that wouldn't be acceptable because M buffer is a private member of the string class but since we've declared this operator as a friend we can now write code like this beautiful so if I go back to men and I write my string variable here I'll just set it equal to shadow and then I'll just pop it in to see house like that all right looks pretty good hit fNUMBER_TOKEN and there we have our shadows string printing you can see it's accompanied by a lot of other random characters because we don't have that null termination character so let's go ahead and add that in the way I'm going to do that is just when I allocates a buffer I'm going to do M size plus NUMBER_TOKEN you could also use string copy which one I'm going to talk about for now but I'm just gonna allocate m / + NUMBER_TOKEN to make room for that we know that this string does have a null termination character so to make this easy I could write code like this which kind of seems to copy over the length of this if I hit at NUMBER_TOKEN this will work but this is working under the assumption that this string that this child pointer is actually properly not terminated if we can't guarantee that just to be a bit safe I'm just going to set m buffer m size here equal to NUMBER_TOKEN like this manually adding my own null termination character at the end of this hit fNUMBER_TOKEN and we should be good and you can see that we are well finally writing some actual code in this series really excited about that hope I'm not going too fast I'm kind of trying to rush through this this is mostly basic kind of there's me kind of setting up the string class so that I can actually show you the copying which is what this videos about so if you have any questions about anything I wrote in this kind of segment or another I guess maybe other sections of this video where I rush through things the best place to ask these questions is to join my discord server there'll be a link in description if you just go to the channel to calm slash discord then you'll be able to join that server and you can talk to a lot of people about how all this works and I'll be there as well to explain this stuff too if you don't get it okay so we've got a basic set up here and everything looks pretty good we've actually got a bit of a memory leak here that we should really fix and that is when we allocate this new char right here we never delete it if we use a smart pointer or a vector we wouldn't need to but since we're using the new keyword and we're allocating a raw array we have to actually delete it over here by calling delete buffer in the destructor okay fantastic so if we launch this code we'll just verify that our program Gemini successful and you can see it does now let's try to copy this string so the way so in this scenario maybe I want to print out this string and then later on I actually want to print I want to make an adjustment to this string I'll
START_SELFPROMO_TOKEN if you have any questions about anything I wrote in this kind of segment or another I guess maybe other sections of this video where I rush through things the best place to ask these questions is to join my discord server there'll be a link in description if you just go to the channel to calm slash discord then you'll be able to join that server and you can talk to a lot of people about how all this works and I'll be there as well to explain this stuff too if you don't get END_SELFPROMO_TOKEN