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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:38:30+00:00 2026-06-15T22:38:30+00:00

Is this a mistake? I thought private members are not inherited from the base

  • 0

Is this a mistake? I thought private members are not inherited from the base class:

“The definition of the class HourlyEmployee does not mention the member variables name, ssn, and netPay, but every object of the class HourlyEmployee has member variables namedname, ssn, and netPay. The member variables name, ssn, and netPay are inherited from the class Employee.”

 //This is the header file hourlyemployee.h.
 //This is the interface for the class HourlyEmployee.
 #ifndef HOURLYEMPLOYEE_H
 #define HOURLYEMPLOYEE_H

 #include <string>
 #include "employee.h"
 using std::string;


namespace SavitchEmployees
{
class HourlyEmployee : public Employee
{
public:
    HourlyEmployee( );
    HourlyEmployee(const string& theName, const string& theSsn,
    double theWageRate, double theHours);
    void setRate(double newWageRate);
    double getRate( ) const;
    void setHours(double hoursWorked);
    double getHours( ) const;
    void printCheck( );
private:
    double wageRate;
    double hours;
};
 }//SavitchEmployees
 #endif //HOURLYEMPLOYEE_H

Other header file:

//This is the header file employee.h.
//This is the interface for the class Employee.
//This is primarily intended to be used as a base class to derive
//classes for different kinds of employees.
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
#include <string>

using std::string;

namespace SavitchEmployees
{
    class Employee
    {
    public:
        Employee( );
        Employee(const string& theName, const string& theSsn);
        string getName( ) const;
        string getSsn( ) const;
        double getNetPay( ) const;
        void setName(const string& newName);
        void setSsn(const string& newSsn);
        void setNetPay(double newNetPay);
        void printCheck( ) const;
    private:
        string name;
        string ssn;
        double netPay;
    };
}//SavitchEmployees

#endif //EMPLOYEE_H
  • 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-15T22:38:31+00:00Added an answer on June 15, 2026 at 10:38 pm

    All members are inherited by subclasses. They just can’t be accessed (directly) if they’re private. They can still be accessed indirectly by calling public methods such as setName.

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

Sidebar

Related Questions

I know this doubt could be silly mistake. I am getting a variable from
I'm pretty sure this is some stupid mistake from me but i haven't been
I used voice recognition sample code from existing one.But this code not working in
Suppose I have a class like this: class MyClass { private: vector<MyOtherClass> myMember; public:
Ok, so I thought I had this nailed , but sadly not . I
Maybe it is just a simple mistake but this thing is driving me crazy.
I can't see a clear mistake in this code. Instead of validating my fields,
This seems very foolish mistake, I just did a git stash pop on a
This is for certain a newbie mistake, I have googled for plenty of hours
Hopefully this is just a stupid mistake, but I can't see it. ; OK

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.