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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:59:44+00:00 2026-06-03T21:59:44+00:00

a struct has public inheritance by default what does this statement really mean? And

  • 0

“a struct has public inheritance by default” what does this statement really mean? And why is the following code in error just because I have omitted the keyword ‘public’ while deriving the class d from c??

struct c 
{
protected:
    int i;
public:
    c(int ii=0):i(ii){} 
    virtual c *fun();
};

c* c::fun(){
    cout<<"in c";
    return &c();
}

class d : c
{  
public:
    d(){}
    d* fun()
    {
        i = 9;
        cout<<"in d"<<'\t'<<i;
        return &d();
    }
};


int main()
{
    c *cc;
    d dd;
    cc = &dd;
    cc->fun();
}
  • 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-06-03T21:59:46+00:00Added an answer on June 3, 2026 at 9:59 pm

    It means that

    struct c;
    struct d : c
    

    is equivalent to

    struct d : public c
    

    Your code is a class extending a struct:

    struct c;
    class d : c;
    

    is equivalent to

    class d : private c;
    

    because class has private inheritance by default.

    And it means that all inherited and not overriden/overloaded/hidden methods from c are private in d.

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

Sidebar

Related Questions

Why does the follwing code produce this error even though c is a struct
Consider the following code: struct Vec2 : IEquatable<Vec2> { double X,Y; public bool Equals(Vec2
I have the following code: namespace FVProductions.Base { public struct Color { public byte
An exportable function has a struct as a one of the parameters. This DLL
This code has an interesting bug: some_struct struct_array1[10] = {0}; some_struct struct_array2[10] = {0}
ProjectileManager inherits from EntityManager, which has this as a protected member: struct EntityDeallocator{ void
Code snippet to follow. I have a struct (example code has class, tried both,
I have a legacy VB6 application that has the following structure defined: Public Type
take two following classes: class Test1{ public: Test1()=default; Test1(char in1,char in2):char1(in1),char2(in2){} char char1; char
I cannot compile my because of this error in my header: error: expected identifier

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.