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

Virtual Functions in C++

456.3K views
•
August 11, 2017
by
The Cherno
YouTube video player
Virtual Functions in C++

TL;DR

Virtual functions in C++ allow the overriding of methods in subclasses, providing flexibility and polymorphism.

Transcript

hey what's up guys my name is HMO and welcome back to my syphilis gloss series today I'm going to be talking about virtual functions in c++ over the last two episodes we've been talking about classes and object-oriented programming and inheritance and all that stuff and virtual functions are really really important to that whole concept virtual fun... Read More

Key Insights

  • 👻 Virtual functions allow for flexibility and polymorphism by enabling the overriding of methods in subclasses.
  • 🥰 V tables are used to determine the correct overridden function to call at runtime.
  • 💋 Marking a base function as "virtual" is necessary to indicate its potential for overriding.

Install to Summarize YouTube Videos and Get Transcripts

Explore YouTube Video Summarizer or Get YouTube Transcript Extractor

Questions & Answers

Q: What are virtual functions in C++?

Virtual functions in C++ allow the overriding of methods in subclasses, enabling polymorphism. They provide flexibility and the ability to treat objects of derived classes as objects of their base class type.

Q: How are virtual functions implemented in C++?

C++ uses V tables, which are tables that contain a mapping for all the virtual functions in a base class. These tables allow the compiler to determine the correct overridden function to call at runtime.

Q: What happens if a virtual function is not marked with the keyword "virtual"?

If a virtual function in a base class is not marked with the keyword "virtual," it will not be eligible for overriding in derived classes. It is important to mark the base function as "virtual" to indicate its potential for overriding.

Q: Are virtual functions free to use in terms of performance?

There are some runtime costs associated with virtual functions, such as the additional memory required to store the V table and the performance penalty of looking up the correct function at runtime. However, in most cases, the impact is minimal, and the benefits of using virtual functions outweigh the costs.

Key Insights:

  • Virtual functions allow for flexibility and polymorphism by enabling the overriding of methods in subclasses.
  • V tables are used to determine the correct overridden function to call at runtime.
  • Marking a base function as "virtual" is necessary to indicate its potential for overriding.
  • There are some runtime costs associated with virtual functions, such as memory usage and performance penalties, but they are generally minimal and do not significantly impact performance in most cases.

Summary & Key Takeaways

  • Virtual functions in C++ allow the overriding of methods in subclasses, enabling polymorphism.

  • By marking a base function as virtual, C++ generates a V table that maps overridden functions to the correct function at runtime.

  • Virtual functions come with a small runtime cost in terms of additional memory and performance.


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 The Cherno 📚

Destructors in C++ thumbnail
Destructors in C++
The Cherno
What Are Pointers in C++ and How Do They Work? thumbnail
What Are Pointers in C++ and How Do They Work?
The Cherno
How to REALLY learn C++ thumbnail
How to REALLY learn C++
The Cherno
Static in C++ thumbnail
Static in C++
The Cherno
How the C++ Compiler Works thumbnail
How the C++ Compiler Works
The Cherno
How to DEBUG C++ in VISUAL STUDIO thumbnail
How to DEBUG C++ in VISUAL STUDIO
The Cherno

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.