Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4579202
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:36:31+00:00 2026-05-21T20:36:31+00:00

I am reading some C++ text regrading Pure Virtual Functions. As the text says,

  • 0

I am reading some C++ text regrading Pure Virtual Functions. As the text says, the form of Pure Virtual Functions declaration, for example, is:

virtual void virtualfunctioname() = 0;

And the text explains: “Since pure virtual function has no body, the programmer must add the notation =0 for declaration of the pure virtual function in the base class.”

I have tried to remove = 0;, that means I only declared virtual void virtualfunctioname(); and things worked fine.

So, why do we need to assign a 0 to the virtual function?
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T20:36:32+00:00Added an answer on May 21, 2026 at 8:36 pm

    If a class has any pure virtual functions, it cannot be instantiated. Also, it forces any derived classes to implement those functions, otherwise they too cannot be instantiated.

    So if you remove the = 0, you’ll just have a normal base class, which may be instantiated, and doesn’t enforce an interface on its derived classes. You’ll only get into trouble if you instantiate a base-class object (or a derived-class object with no override), and then try to invoke virtualfunctionname() on it, because there’s no definition for it, so the linker will complain.

    [Note, also the claim that “pure virtual functions have no body” is incorrect; you may define an implementation for a pure virtual. The class will still be abstract, though.]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading some Java text and the text says that we can only
I have some code reading a text file and scanning for words between brackets:
I've trying to get some vertical text on a little test webpage after reading
I am reading a text file which I guess is encoded in utf-8. Some
Reading some Python (PyQt) code, I came across as follows. @pyqtSignature(QString) def on_findLineEdit_textEdited(self, text):
I was reading some C++ text at the address: http://www.parashift.com/c++-faq-lite/new/istream-and-while.html . According to the
I am reading some C++ text and got the following code: class A {
I am reading some C++ text and got the following code: From that code,
Alright so I'm reading some scores off of a text file and when the
Possible Duplicate: Reading csv file I have a comma delimited file: Some Text, More

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.