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

  • SEARCH
  • Home
  • 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 7888971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:58:32+00:00 2026-06-03T05:58:32+00:00

Please don’t question the really odd hierarchy of workers in this code here, I

  • 0

Please don’t question the really odd hierarchy of workers in this code here, I have no idea why anyone would want something like this, but I decided to give myself an exercise in Multiple Inheritance, just to be sure I fully understood it. So here’s the result.

using namespace std;

class Employee
{
protected:
    string name;
public:
    string getname()
    {
        return name;
    }
    void setname(string name2)
    {
        name = name2;
    }
    Employee(string name2)
    {
        name = name2;
    }
    Employee(){}
};

class Manager : public Employee
{
public:
    string getname()
    {
        return ("Manager" + name);
    }
    Manager(string name2) : Employee(name2){}
    Manager() : Employee(){}
};

class Supervisor : public Manager,public Employee
{
public:
    Supervisor(string name2) : Manager(name2) , Employee(name2){}
    Supervisor() : Manager() , Employee(){}
    string getname()
    {
        return ("Supervisor" + Employee::getname());
    }
};

Hopefully you’re understanding what I’m trying to do here. I’m getting something about an “ambiguous conversion between derived class ‘Supervisor’ and base class ‘Employee.'” So what do I do?

  • 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-03T05:58:33+00:00Added an answer on June 3, 2026 at 5:58 am

    Actually, the way you have defined Supervisor class, its object will have two subjects of type Employee, each coming from it base classes. That is causing problem.

    The solution is to use virtual inheritance (assuming you need multiple inheritance) as:

    class Manager : public virtual Employee 
    

    Hope you note the virtual keyword here. 🙂

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

Sidebar

Related Questions

I know this is a rather odd question, please don't flame me :) I
I have a bunch of php arrays that look like this (please don't ask
Ok I don't want this to be a hacking advice question, so please don't
A very basic conceptual doubt. Please don't hate me for this silly question If
I have a very amateurish question, so please don't bomb me. I work in
Firstly, please don't dismiss this question - I'm aware it's an ugly situation but
So first off, this is a homework assignment, so please don't write any code
important ; I'm really looking for a StructureMap answer here. Please don't say how
Please don't crucify me for this one. I decided it might be good to
Please don't confuse my question with determining the key press. I don't want the

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.