Question

Language: C++

Create an abstract base class person.

The person class must be an abstract base class where the following functions are abstracted (to be implemented in Salesman a

0 0
Add a comment Improve this question Transcribed image text
Answer #1

your question was very much longer but I try to clear your dought.

in this, I did not mention the main function I hope you will do that but I have tried to explain to you a method of a pure virtual function, abstract base class and Inherit person class method.

I have also tried to explain to your role of default constructor and parameterize constructor.

A class is abstract if it has at least one pure virtual function. So if we want to declare an abstract class then we have to declare a pure virtual function inside the class.


#include<iostream>
using namesapce std;


// we can define an abstract class as a base using a pure virtual function.
class Base // An abstract class
{
   virtual void setPosition()=0;
   virtual void getPosition()=0;
virtual void getTotalSalary()=0;
virtual void printDetails()=0;

};


// This class inherits from Base class

class Person: public Base
{
private:
string name;
int age;
float height;
Public:
Person(); // default constructer
Person(string nameIn, int ageIn, float heightIn) // constructer to assign value to variables.
{
name=nameIn;
age=ageIn;
heihgt=heightIn;
}
void setName(string in) // nameset
{
name=in;
}
void getname() // get name in form to return name;
{
   return name;
}
void setheight(float in) // set height
{
height=in;
}
void getHeight() // return height
{
  
return height;
}
void setAge(float in) // set age
{
age=in;
}
void getAge() // return height;
{
  
   return height;
}

  
};

Add a comment
Know the answer?
Add Answer to:
Language: C++ Create an abstract base class person. The person class must be an abstract base...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Language: C++ Create a class named 'Salesman' that shall inherit from a class called 'Person' and...

    Language: C++ Create a class named 'Salesman' that shall inherit from a class called 'Person' and will add various functionality. We will store the following private variables specific to Warehouse: . a std::vector of float values which indicate the monetary values of each sale made by this salesman . a std::string which stores that salesman's position title . a float which stores their commission percentage, i.e., the percentage of sales they receive as a paycheck . a float which stores...

  • All question base on Java Se 8 Consider the Top class i public abstract class Topí...

    All question base on Java Se 8 Consider the Top class i public abstract class Topí 2 private 3 protected String name; 4 public intx - 12; int age; e public Top(String name)[ this.namename age0; System.out.println(x); 10 12 public abstract void foo(String f); 13 Create a Middle class that extends the Top class. The class should have a single constructor that takes two input parameters: a String (for name) and int (for age). Your constructor should not have any redundant...

  • JAVA QUESTION 16 Write and submit the java source for the following class specification: The name...

    JAVA QUESTION 16 Write and submit the java source for the following class specification: The name of the class is Question_16 Class Question_16 has 3 instance variables: name of type String, age of type int and height of type double. Class Question_16 has the following methods: print - outputs the data values stored in the instance variables with the appropriate label setName - method to set the name setAge - method to set the age setHeight - method to set...

  • c++ please need help with this question Consider a class Employee with data members: age(an integer),...

    c++ please need help with this question Consider a class Employee with data members: age(an integer), id (an integer) and salary (a float), and their corresponding member functions as follows: class Employee {        private:             int age;             int id;             float salary;        public:             Employee( ); // default constructor: age=0, id=0, and salary=0             Employee(Employee &x);   // copy constructor           Employee& operator = (Employee &x); // equal sign operator             void setAge(int x);    // let age = x...

  • Create a UML diagram to help design the class described in exercise 3 below. Do this...

    Create a UML diagram to help design the class described in exercise 3 below. Do this exercise before you attempt to code the solution. Think about what instance variables will be required to describe a Baby class object; should they be private or public? Determine what class methods are required; should they be private or public? Write Java code for a Baby class. A Baby has a name of type String and an age of type integer. Supply two constructors:...

  • Assignment (to be done in Java): Person Class: public class Person extends Passenger{ private int numOffspring;...

    Assignment (to be done in Java): Person Class: public class Person extends Passenger{ private int numOffspring; public Person() {    this.numOffspring = 0; } public Person (int numOffspring) {    this.numOffspring = numOffspring; } public Person(String name, int birthYear, double weight, double height, char gender, int numCarryOn, int numOffspring) {    super(name, birthYear, weight, height, gender, numCarryOn);       if(numOffspring < 0) {        this.numOffspring = 0;    }    this.numOffspring = numOffspring; } public int getNumOffspring() {   ...

  • Create an abstract class “Appointment” that represents an event on a calendar. The “Appointment” class will...

    Create an abstract class “Appointment” that represents an event on a calendar. The “Appointment” class will have four instance variables: • An instance variable called “year” which will be of type int • An instance variable called “month” which will be of type int • An instance variable called “day” which will be of type int • An instance variable called “description” which will be of type String The “Appointment” class must also implement the following methods: • A getter...

  • C# programming 50 pts Question 2:2 1- Create the base class Book that has the following instance variables, constructor, and methods title (String) isbn (String) authors (String) publisher (Strin...

    C# programming 50 pts Question 2:2 1- Create the base class Book that has the following instance variables, constructor, and methods title (String) isbn (String) authors (String) publisher (String) edition ( int) published year (int) Constructor that takes all of the above variables as input parameters. set/get methods ToString method// that return sting representation of Book object. 2-Create the sub class New_Book that is derived from the base class Book and has the following instance variables, constructor, and methods: title...

  • I have done a decent amount of coding... but I need you to help me understand...

    I have done a decent amount of coding... but I need you to help me understand what I do not. Please, post comments so that I can learn from you. Here are the instructions for this portion of the project: Create the Monkey class, using the specification document as a guide. The Monkey class must do the following: Inherit from the RescueAnimal class Implement all attributes with appropriate data structures Include accessors and mutators for all implemented attributes Here is...

  • c++ program Implement a class called Person with the following members: 1a. ????, a private variable...

    c++ program Implement a class called Person with the following members: 1a. ????, a private variable of type ?????? 1b. ???, a private variable of type ??? 1c. Default constructor to set name to "" and age to 0 1d. Non-default constructor which accepts two parameters for name and age 1e. A copy constructor 1f. The post-increment operator 1g. The pre-decrement operator 1h. The insertion and extraction stream operators >>and <<

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT