Friend Functions | C++ Tutorial

  Рет қаралды 11,256

Portfolio Courses

Portfolio Courses

Күн бұрын

Пікірлер: 20
@yahyaamjad7183
@yahyaamjad7183 Жыл бұрын
I just want to say that you are one of the best to simplify the subject and explain it keep going man ,thanks
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You're welcome Yahya and thank you so much for the kind feedback, I'm so glad to hear the videos are helping to simplify the subjects for you! :-)
@ahmadjawmar2242
@ahmadjawmar2242 4 ай бұрын
you are the greatest teacher ,thanks buddy
@PortfolioCourses
@PortfolioCourses 4 ай бұрын
You’re welcome, I’m glad you enjoyed it! :-)
@artemiasalina1860
@artemiasalina1860 4 ай бұрын
These tutorial videos are very good. One question here: How do friend functions deal with templated classes, is there anything that needs to be done? For example, let's say the double_x(MyClass &object) multiplies x * 2.0 but x is a template variable and could be an int. How do you set double_x() to handle that case?
@Vichained
@Vichained 2 жыл бұрын
good video Kevin!
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Thanks Victor! :-)
@gedariaofficial8818
@gedariaofficial8818 Жыл бұрын
Isn't friend function violation of Opened/Closed principle? When you change your private members, it will break the friend functions that are declared somewhere else in the program. Also isn't it violation of encapsulation as well? Why bother with private specifier if you can write function that can freely access private members? Are friend functions considered a good practice? I am fairly new, please correct me if I am wrong.
@PortfolioCourses
@PortfolioCourses Жыл бұрын
These are really excellent 'deep' questions. :-) I would say that there is room for opinion though in the answers in that the answers are more complicated than 'yes' or 'no'. My opinion... very strictly speaking, friend functions can violate encapsulation, but in some sense all public member functions can violate encapsulation as well (they can also access private members, and break the motivation/point of encapsulation in the process). Like public member functions, friend functions are a good practice when used appropriately. You'll find lots of opinions/prescriptions on this sort of thing online: www.google.com/search?&q=do+friend+function+violates+encapsulation. I don't really take very strong positions on topics like this myself because I'm more of a pragmatic "if it's better than the alternatives, then use it" sort of developer. :-)
@ValliNayagamChokkalingam
@ValliNayagamChokkalingam Жыл бұрын
Hi! How do you decide between using a reference to an object instance vs an object instance directly as a parameter for a function? Thank you! Have a good one!
@phoe87
@phoe87 10 ай бұрын
I know it's 10 months late but in case you haven't figured it out already, passing an instance of a class as a parameter copies it, you either have to pass it by reference when it's instantiated on the stack, or by pointer when it's instantiated on the heap (a pointer to the stack works too)
@sadaqatali-y4n
@sadaqatali-y4n Жыл бұрын
which environment setup you are using
@Vichained
@Vichained 2 жыл бұрын
WIll you cover SFML or some GUI with C++ ofc?
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
I hope to cover GUIs “one day” but I’m not sure when it will be. :-)
@shafayet0198
@shafayet0198 Жыл бұрын
What is the difference between assigning an array like " int arr[n] = {0}; " and using a loop or function?
@PortfolioCourses
@PortfolioCourses Жыл бұрын
We can expect int arr[n[] = {0}; to be more efficient compared to using a loop or function. In that case the compiler "knows everything it needs to know" to initialize the array when compiling the program. Whereas with a loop or function we'll be "executing code at runtime" to initialize the array, potentially with different values each time. We an expect using a loop or a function to create more work to be done at runtime as the program is executing.
@faruqnad4758
@faruqnad4758 2 жыл бұрын
Good job
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Thank you Faruq! :-)
@aryanviolett4606
@aryanviolett4606 11 ай бұрын
Thanks :)
@WhereToClick
@WhereToClick 3 ай бұрын
Thank you!
Operator Overloading Using Friend Functions | C++ Tutorial
15:04
Portfolio Courses
Рет қаралды 10 М.
Exception Handling | C++ Tutorial
14:49
Portfolio Courses
Рет қаралды 23 М.
#behindthescenes @CrissaJackson
0:11
Happy Kelli
Рет қаралды 27 МЛН
-5+3은 뭔가요? 📚 #shorts
0:19
5 분 Tricks
Рет қаралды 13 МЛН
Вопрос Ребром - Джиган
43:52
Gazgolder
Рет қаралды 3,8 МЛН
Andro, ELMAN, TONI, MONA - Зари (Official Audio)
2:53
RAAVA MUSIC
Рет қаралды 8 МЛН
C++ CONSTRUCTORS explained easy 👷
8:55
Bro Code
Рет қаралды 29 М.
Member Initializer Lists | C++ Tutorial
23:10
Portfolio Courses
Рет қаралды 10 М.
Dynamic Binding (Polymorphism) With The Virtual Keyword | C++ Tutorial
9:57
Friend functions and classes in C++ (Programming for beginners)
18:18
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 843 М.
C++ Polymorphism and Virtual Member Functions [6]
12:13
Professor Hank Stalica
Рет қаралды 18 М.
new & delete Operators For Dynamic Memory Allocation | C++ Tutorial
15:52
Portfolio Courses
Рет қаралды 34 М.
Multiple Inheritance Deep Dive | C++ Tutorial
14:53
Portfolio Courses
Рет қаралды 11 М.
Function Templates | C++ Tutorial
10:54
Portfolio Courses
Рет қаралды 9 М.
#behindthescenes @CrissaJackson
0:11
Happy Kelli
Рет қаралды 27 МЛН