C++: Operators and Type Conversion with Constructors

Channel:
Subscribers:
2,650
Published on ● Video Link: https://www.youtube.com/watch?v=AI0uTkkYkUU



Duration: 1:08:12
346 views
12


Today we made a capital-I Integer class that behaves like a normal int in C++ but it cannot ever be uninitialized. C++ allows you to add operators to a type so that you can do things like + and - with it.

Constructors are used in C++ not only for creating new objects, but are also used to implicitly convert between types as well, unless you use the explicit keyword in front of them.

Finally, we talked a bit about friend functions, and how you can mark something as a friend to get access to the private member variables and functions inside of a class that they normally wouldn't have access to. I use it mostly to package global functions inside of a class to make it look tidier.