 Everybody, it's Brian. This is our 22nd video. Today, we're going to be covering constructors. If you remember from the last one, we have our cat class, and we're simply setting the age and then printing it back out. Well, at the end of the last video, I said you really should initialize your variables. How are you going to do that? One way is the constructor. Say, int mh. This would be our second constructor. This would be our default constructor. Notice how you can have multiple constructors. And then to implement this, you say cat. Cat. And it has to have the same signature or it will generate an error message. Let's actually do this. Copy and paste that out there. And we're going to say creating cat with age. That way we know what constructor was just called. And then we will just set age and whatever the value of mh is. That way when this constructor is called, we're going to take the first parameter called mh and we're going to actually set our private variable age using the set age function. Sounds really complex, but I guarantee it's not. It's actually pretty simple once you look at it. Let's go back into our code here. We have two instances of the cat class. Let's actually just comment one of these out just so we don't have a bunch of clutter here. So we are creating an instance of the cat class. And then we're printing it out. Now notice we haven't set the age. To call the constructor, just put a parenthesis. And notice I have two options here. You have the default and the one we just created. So we'll say she's 22 years old, really old cat. Now when you run this, the constructor is called and it's setting the age and there is our variable. So that's one way to initialize. Now let's say you don't want to use a pointer. You would just want to create a normal cat class here. When we do that, you just add the parenthesis here. Now you notice how you don't have the option to do the other. You can't really just do that. I think you can, but some compilers that will actually throw an error. So we'll say cat 33. And we'll do the cout mcat get age. That way you can see how this works with and without pointers. See cat, what did we do wrong here? Oh yeah. I forgot to comment that out. Can't delete memory we didn't initialize. Sure enough, creating cat with age 33. So that's one way of initializing your variables. Another way would be actually in your default constructor, call another function. For example, just set age 17 if you wanted a specific value. So this is Brian and thank you for watching. I hope you found this video educational and entertaining.