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 6773843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:42:59+00:00 2026-05-26T15:42:59+00:00

So I’m learning about inheritance in my c++ class now and trying to put

  • 0

So I’m learning about inheritance in my c++ class now and trying to put all the terminology to light. I understand the difference between protected and private. But when you make a function a friend isn’t that the same thing as making it public?

The examples they are using to teach inheritance is shapes, so:

class shape{
   struct circle
   struct rectangle
   struct line
}

Something like that, what is the difference between saying

class circle: shape
class circle: public shape
class circle: private shape (don't actually know if this one is possible)

And finally, what does the keyword virtual mean/do/used for? Thank you

  • 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-26T15:42:59+00:00Added an answer on May 26, 2026 at 3:42 pm

    First and foremost you should pick up a good C++ book and read the concepts:

    The Definitive C++ book and guide list


    To get you started little brief about your Questions:

    Your first example is an example of Composition not Inheritance.
    Inheritance is IS A relationship.
    Composition is HAS A relationship.

    In the example, Circle IS A type of Shape.


    class circle: shape 
    

    is same as:

    class circle: private shape 
    

    For a class, Default Access specifier is Private by default. This is Private Inheritance. Class circle privately derives from class shape.

    In Private Inheritance all the public and protected members of the Base class become Private members of the Derived class.

    class circle: public shape 
    

    Is Public Inheritance, Class circle publically derives from class shape.

    In Public Inheritance the public members of Base class become Public members of Derived class and protected members of the Base class become Protected members of the Derived class.

    This C++-Faq should be a good read for understanding the basics:
    What are access specifiers? Should I inherit with private, protected or public?


    But when you make a function a friend isn’t that the same thing as making it public?
    When you make a function as friend of an class, Access specifiers no longer apply to that function. That function can access, protected as well as private members of that class.But this is only limited to that function.


    what does the keyword virtual mean/do/used for?
    The keyword virtual is used to implement Dynamic/Run-Time Polymorphism.
    It is an broad term to be explained as such, So it is upmost important that you read and understand the concept from an book. If you still face problems in understanding anything specific about it,Come back here and feel free to ask an Specific Question here.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.