Products
Features
YouTube Video Summarizer
Summarize YouTube videos
Web & PDF Highlighter
Highlight web pages & PDFs
Chat with PDF
Ask any PDF questions with AI
Ask AI Clone
Chat with your highlights & memories
Audio Transcriber
Transcribe audio files to text
Glasp Reader
Read and highlight articles
Kindle Highlight Export
Export your Kindle highlights
Idea Hatch
Hatch ideas from your highlights
Integrations
Obsidian Plugin
Notion Integration
Pocket Integration
Instapaper Integration
Medium Integration
Readwise Integration
Snipd Integration
Hypothesis Integration
Apps & Extensions
Chrome Extension
Safari Extension
Edge Add-ons
Firefox Add-ons
iOS App
Android App
Discover
Discover
Ideas
Discover new ideas and insights
Articles
Curated articles and insights
Books
Book recommendations by great minds
Posts
Essays and notes from readers
Quotes
Inspiring quotes collection
Videos
Curated videos and summaries
Explore Glasp
Glasp Newsletter
Weekly insights and updates
Glasp Talk
Interview series with great minds
Glasp Blog
Latest news and articles
Glasp Use Cases
Learn how others use Glasp
Build & Support
Glasp API
Access Glasp's API for developers
MCP Connector
Connect Glasp to Claude & ChatGPT
Community
Glasp Reddit Community
Students
Student discount and benefits
FAQs
Frequently Asked Questions
AboutPricing
DashboardLog inSign up

Friend Function | CPP Object Oriented Programming Video Tutorial

130.6K views
•
January 9, 2014
by
LearningLad
YouTube video player
Friend Function | CPP Object Oriented Programming Video Tutorial

TL;DR

Friend functions in C++ allow non-member functions or classes to access the private members of a class.

Transcript

hi this is Anil and welcome to the video tutorial for the learning light on C++ programming so in this tutorial we're going to learn about the friend functions in C++ all of you know that you know in a class the private and the protected members of their class are only accessible to the member functions of that class so they are not accessible to t... Read More

Key Insights

  • 🏫 Friend functions in C++ allow accessing private and protected members of a class from outside the class's member functions.
  • 👥 By making a function a friend to a class, all properties and members of the class become accessible in that function.
  • 📚 The friend function can be declared using the "friend" keyword followed by the return type and function name.
  • 🔒 Private properties of a class are only accessible to member functions, but friend functions can access them as well.
  • 🔑 Friend functions in C++ can be used to share private information between classes, similar to sharing information with friends.
  • ➡️ A friend function can be declared within the class and defined outside the class using the scope resolution operator.
  • 🤝 A class can also be declared as a friend to another class, allowing all member functions of the friend class to access the members of the class.
  • ✅ Friend functions in C++ provide a way to grant access to private members of a class to specific functions or classes, improving flexibility in programming.

Install to Summarize YouTube Videos and Get Transcripts

Explore YouTube Video Summarizer or Get YouTube Transcript Extractor

Questions & Answers

Q: What are friend functions in C++ and how do they work?

Friend functions in C++ are functions that are not a part of a class but are declared as friends to the class, allowing them to access the private members of the class. This is achieved by using the keyword "friend" before the function declaration. By declaring a function as a friend, it becomes an exception to the normal accessibility rules and can access all the private members of the class.

Q: How are friend functions different from member functions?

Friend functions are not member functions of a class but have the ability to access the private members of the class. Unlike member functions, friend functions are not bound to any particular object of the class. They can be called independently, without the need for an object of the class.

Q: Can a friend function modify the private members of a class?

Yes, a friend function has the ability to modify the private members of a class. Since it has direct access to the private members, it can read and modify their values. This allows for more flexibility in the design and implementation of functions that require access to private members.

Q: What is the syntax for declaring a friend class in C++?

To declare a class as a friend to another class, the keyword "friend" is used followed by the keyword "class" and the class name. This allows all the member functions of the friend class to access the private members of the other class.

Summary & Key Takeaways

  • Friend functions in C++ allow non-member functions to access the private members of a class.

  • When a function is declared as a friend to a class, it can access all the members of that class.

  • Similarly, an entire class can also be declared as a friend to another class, allowing all the member functions of the friend class to access the members of the other class.


Read in Other Languages (beta)

English

Share This Summary 📚

Summarize YouTube Videos and Get Video Transcripts with 1-Click

Download browser extensions on:

Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator

Explore More Summaries from LearningLad 📚

C++ Operator Overloading Introduction | Plus + Operator | Video Tutorial thumbnail
C++ Operator Overloading Introduction | Plus + Operator | Video Tutorial
LearningLad
How Does C++ Convert Source Code to Executable Files? thumbnail
How Does C++ Convert Source Code to Executable Files?
LearningLad
fscanf Function in C Programming Language Video Tutorial thumbnail
fscanf Function in C Programming Language Video Tutorial
LearningLad
C++ Source Code to Executable | Compilation, Linking, Pre Processing | Build Process Explained thumbnail
C++ Source Code to Executable | Compilation, Linking, Pre Processing | Build Process Explained
LearningLad

Summarize YouTube Videos and Get Video Transcripts with 1-Click

Download browser extensions on:

Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator

Apps & Extensions

  • Chrome Extension
  • Safari Extension
  • Edge Add-ons
  • Firefox Add-ons
  • iOS App
  • Android App

Key Features

  • YouTube Video Summarizer
  • Web & PDF Summarizer
  • Web & PDF Highlighter
  • Chat with PDF
  • Ask AI Clone
  • Audio Transcriber
  • Glasp Reader
  • Kindle Highlight Export
  • Idea Hatch

Integrations

  • Obsidian Plugin
  • Notion Integration
  • Pocket Integration
  • Instapaper Integration
  • Medium Integration
  • Readwise Integration
  • Snipd Integration
  • Hypothesis Integration

More Features

  • APIs
  • MCP Connector
  • Blog & Post
  • Embed Links
  • Image Highlight
  • Personality Test
  • Quote Shots

Company

  • About us
  • Blog
  • Community
  • FAQs
  • Job Board
  • Newsletter
  • Pricing
Terms

•

Privacy

•

Guidelines

© 2026 Glasp Inc. All rights reserved.