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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:24:06+00:00 2026-06-15T14:24:06+00:00

I am working on C++ project that uses inheritance. I seem to have an

  • 0

I am working on C++ project that uses inheritance. I seem to have an error in visual studio in the below file administrator.h. It says that salariedemploye:salary on line 17 is inaccessible and I am not sure why.

Admin.cpp

#include

namespace SavitchEmployees
{
    Administrator::Administrator( ):SalariedEmployee(), salary(0)
    {
        //deliberately empty
    }

    Administrator::Administrator(const string& theName, const string& theSsn, double theAnnualSalary)
      :SalariedEmployee(theName, theSsn),salary(theAnnualSalary)
    {
        //deliberately empty
    }

    void Administrator::inputAdminData()
    {
        cout << " Enter the details of the administrator " << getName() << endl;
        cout << " Enter the admin title" << endl;
        getline(cin, adminTitle);
        cout << " Enter the area of responsibility " << endl;
        getline(cin, workingArea);
        cout << " Enter the immediate supervisor's name " << endl;
        getline(cin, supervisorName);
    }

    void Administrator::outputAdminData()
    {
        cout << "Name: " << getName() << endl;
        cout << "Title: " << adminTitle << endl;
        cout << "Area of responsibility: " << workingArea << endl;
        cout << "Immediate supervisor: " << supervisorName << endl;
    }

    void Administrator::printCheck()
    {
        setNetPay(salary);
        cout << "\n___________________________________\n"
             << "Pay to the order of " << getName() << endl
             << "The sum of" << getNetPay() << "Dollars\n"
             << "______________________________________\n"
             << "Check Stub Not negotiable \n"
             << "Employee Number: " << getSsn() << endl
             << "Salaried Employee(Administrator). Regular Pay: "
             << salary << endl
             << "______________________________________\n";
    }
}

admin.h

#include <iostream>

#include "salariedemployee.h"
using std::endl;
using std::string;

namespace SavitchEmployees
{
    class Administrator : public SalariedEmployee
    {
        public:
            Administrator();
            Administrator(const string& theName, const string& theSsn, double salary);
            double getSalary() const;
            void inputAdminData();
            void outputAdminData();
            void printCheck();
        private:
            string adminTitle;//administrator's title
            string workingArea;//area of responsibility
            string supervisorName;//immediate supervisor
    };
}

#endif

SalariedEmployee.cpp

namespace SavitchEmployees
{
    SalariedEmployee::SalariedEmployee():Employee(),salary(0)
    {
        //deliberately empty
    }
    SalariedEmployee::SalariedEmployee(const string& theName, const string& theNumber, double theWeeklyPay)
      :Employee(theName, theNumber), salary(theWeeklyPay)
    {
        //deliberately empty
    }
    double SalariedEmployee::getSalary() const
    {
        return salary;
    }
    void SalariedEmployee::setSalary(double newSalary)
    {
        salary = newSalary;
    }
    void SalariedEmployee::printCheck()
    {
        setNetPay(salary);
        cout << "\n___________________________________\n"
             << "Pay to the order of " << getName() << endl
             << "The sum of" << getNetPay() << "Dollars\n"
             << "______________________________________\n"
             << "Check Stub NOT NEGOTIABLE \n"
             << "Employee Number: " << getSsn() << endl
             << "Salaried Employee. Regular Pay: "
             << salary << endl
             << "______________________________________\n";
    }
}

Salariedemplyee.h

#ifndef SALARIEDEMPLOYEE_H
#define SALARIEDEMPLOYEE_H

#include <string>
#include "employee.h"

namespace SavitchEmployees{
    class SalariedEmployee : public Employee{
    public:
        SalariedEmployee();
        SalariedEmployee(const string& theName, const string& theSsn, double theWeeklySalary);
        double getSalary() const;
        void setSalary(double newSalary);
        void printCheck();

    private:
        double salary;
    };
}
#endif

employee.cpp

namespace SavitchEmployees
{
    Employee::Employee():name("No name yet"),ssn("No number yet"),netPay(0){}
    Employee::Employee(const string& theName, const string& theSsn):name(theName),ssn(theSsn),netPay(0){}
    string Employee::getName() const
    {
        return name;
    }
    string Employee::getSsn() const
    {
        return ssn;
    }
    double Employee::getNetPay() const
    {
        return netPay;
    }
    void Employee::setName(const string& newName)
    {
        name = newName;
    }
    void Employee::setSsn(const string& newSsn)
    {
        ssn = newSsn;
    }
    void Employee::setNetPay(double newNetPay)
    {
        netPay = newNetPay;
    }
    void Employee::printCheck() const
    {
        cout << "\nERROR: pringCheck function called for an \n" 
             << "Undifferentiated employee. Aborting the program!\n"
             << "Check with the author of this program about thos bug. \n";
        exit(1);
    }
}
  • 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-15T14:24:07+00:00Added an answer on June 15, 2026 at 2:24 pm

    The variable is declared private in Salariedemplyee.h. Change it to protected to use it for inheritance.

    class SalariedEmployee : public Employee{
        public:
            SalariedEmployee();
            SalariedEmployee(const string& theName, const string& theSsn, double theWeeklySalary);
            double getSalary() const;
            void setSalary(double newSalary);
            void printCheck();
    
        private:
            double salary;
        };
    

    The second problem is that the value of a member variable can only be set in the initialization list of a constructor that belongs to the same class as the variable. Use the assignment operator instead.

    Administrator::Administrator(const string& theName, const string& theSsn, double theAnnualSalary)
          :SalariedEmployee(theName, theSsn)
        {
            //deliberately empty
            salary = theAnnualSalary;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a project that uses visual studio's GUI DB designer to
I'm working on a project that uses MOSS 2007. We have user profiles set
I'm working on a project that uses OpenGL 4.0 shaders. I have to supply
I am working on a project that uses VFW. I have done Google searches
I am working on a project that uses a touch-screen interface. I have a
So recently I have been working on phonebook project that uses Binary Search Tree.
I'm working on a JavaScript project that uses Prototypical Inheritance. The way that I
I am working on a project that uses MDI form in java. I have
I'm working on a project that uses several languages: SQL for querying a database
I'm working on a project that uses the new CSS3 transform:rotate(180deg) feature. Every modern

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.