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 a text file with this format: grrr,some text,45.4321,54.22134 I just have
I'm having some trouble with this. I am reading in some text and trying
I am reading some text about the C language at the url https://cs.senecac.on.ca/~btp100/pages/content/compu.html .
I'm reading some text from a local xml file and displaying it in a
I am reading some C text at the address: https://cs.senecac.on.ca/~lczegel/BTP100/pages/content/compu.html In the section: Addressible
I am reading some C++ text from the address https://cs.senecac.on.ca/~chris.szalwinski/archives/btp200.081/content/overl.html . in the first
I would like to do some text conversion, such as reading in from a
After reading some threads on misuses of exceptions (basically saying you don't want to
I'm reading some MPEG Transport Stream protocol over UDP and it has some funky
I was reading some 3rd party code and I found this: x.Flags = x.Flags

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.