PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/TikTok

Differentiate virtual and pure virtual functions

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's understanding of C++ object-oriented polymorphism and interface design, including distinctions between virtual and pure virtual functions, dynamic dispatch via the vtable, overriding semantics, abstract class formation, and lifecycle concerns for constructors and destructors.

  • Medium
  • TikTok
  • Coding & Algorithms
  • Machine Learning Engineer

Differentiate virtual and pure virtual functions

Company: TikTok

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

In C++, what is the difference between a virtual function and a pure virtual function? Provide syntax examples, describe dynamic dispatch via the vtable, and explain how overriding works. When does a class become abstract, and can a pure virtual function still have a definition? Discuss whether constructors or destructors should be virtual, implications for resource management, and guidelines on when to use each in interface design.

Quick Answer: This question evaluates a candidate's understanding of C++ object-oriented polymorphism and interface design, including distinctions between virtual and pure virtual functions, dynamic dispatch via the vtable, overriding semantics, abstract class formation, and lifecycle concerns for constructors and destructors.

Related Interview Questions

  • Parse a nested list from a string - TikTok (medium)
  • Implement stacks, streaming median, and upward path sum - TikTok (easy)
  • Solve common string/DP/stack problems - TikTok (medium)
  • Implement stack variants and path-sum check - TikTok (medium)
  • Maximize sum with no adjacent elements - TikTok (medium)
TikTok logo
TikTok
Aug 8, 2025, 12:00 AM
Machine Learning Engineer
Technical Screen
Coding & Algorithms
3
0

In C++, what is the difference between a virtual function and a pure virtual function? Provide syntax examples, describe dynamic dispatch via the vtable, and explain how overriding works. When does a class become abstract, and can a pure virtual function still have a definition? Discuss whether constructors or destructors should be virtual, implications for resource management, and guidelines on when to use each in interface design.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More TikTok•More Machine Learning Engineer•TikTok Machine Learning Engineer•TikTok Coding & Algorithms•Machine Learning Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.