Question

In: Electrical Engineering

In C++ Demonstrate inheritance. Create an Airplane class with the following attributes: • manufacturer : string...

In C++

Demonstrate inheritance. Create an Airplane class with the following attributes: • manufacturer : string • speed : float Create a FigherPlane class that inherits from the Airplane class and adds the following attributes: • numberOfMissiles : short

Solutions

Expert Solution

Answer :- The demonstration code is written below-

// C++ program to demonstrate implementation

// of Inheritance

#include <bits/stdc++.h>

using namespace std;

//Base class

class Airplane

{

    public:

      char manufacturer[30];

      float speed;

};

// Sub class inheriting from Base Class(Parent)

class FighterPlane : public Airplane

{

    public:

      short int numberOfMissile;

};

//main function

int main()

   {

     

        FighterPlane obj1;

         

        // An object of class FighterPlane has all data members and member functions of class Airplane

       strncpy(obj1.manufacturer, "Truth or Dare", 15);

        obj1.speed = 1234.45;

        obj1.numberOfMissile = 20;

        cout << "Manufacturer is :- " << obj1.manufacturer << endl;

        cout << "Speed is :- " << obj1.speed << endl;

         cout << "Number of missile is :- " << obj1.numberOfMissile << endl;

        return 0;

   }


Related Solutions

Code in C++. Using ONE of the following themes to create a class and demonstrate the...
Code in C++. Using ONE of the following themes to create a class and demonstrate the idea. Use this to create a solution (two ADTs and a driver program) to demonstrate the following concepts. Create a one page summary to describe where you are using each of these concepts. Themes:(PICK ONE) a house has a door a semester has a holiday break a cell phone has a shatterproof case a chair has a cushion Concepts to include: composition separating interface...
Objective: Create an Inheritance Hierarchy to Demonstrate Polymorphic Behavior 1. Create a Rectangle 2. Class Derive...
Objective: Create an Inheritance Hierarchy to Demonstrate Polymorphic Behavior 1. Create a Rectangle 2. Class Derive a Square Class from the Rectangle Class 3. Derive a Right Triangle Class from the Rectangle Class 4. Create a Circle Class 5. Create a Sphere Class 6. Create a Prism Class 7. Define any other classes necessary to implement a solution 8. Define a Program Driver Class for Demonstration (Create a Container to hold objects of the types described above Create and Add...
Please do this in C++ Objective: Create an Inheritance Hierarchy to Demonstrate Polymorphic Behavior 1. Create...
Please do this in C++ Objective: Create an Inheritance Hierarchy to Demonstrate Polymorphic Behavior 1. Create a Rectangle 2. Class Derive a Square Class from the Rectangle Class 3. Derive a Right Triangle Class from the Rectangle Class 4. Create a Circle Class 5. Create a Sphere Class 6. Create a Prism Class 7. Define any other classes necessary to implement a solution 8. Define a Program Driver Class for Demonstration (Create a Container to hold objects of the types...
A. Create a Dollar currency class with two integer attributes and one string attribute, all of...
A. Create a Dollar currency class with two integer attributes and one string attribute, all of which are non-public. The int attributes will represent whole part (or currency note value) and fractional part (or currency coin value) such that 100 fractional parts equals 1 whole part. The string attribute will represent the currency name. B. Create a CIS22C Dollar derived/inherited class with one additional non-public double attribute to represent the conversion factor from/to US Dollar. The value of the conversion...
PYTHON PLEASE: Construct a class “Monster” with the following attributes: self.name (a string) self.type (a string,...
PYTHON PLEASE: Construct a class “Monster” with the following attributes: self.name (a string) self.type (a string, default is ‘Normal’) self.current_hp (int, starts out equal to max_hp) self.max_hp (int, is given as input when the class instance is created, default is 20) self.exp (int, starts at 0, is increased by fighting) self.attacks (a dict of all known attacks) self.possible_attacks (a dictionary of all possible attacks) The dictionary of possible_attacks will map the name of an attack (the key) to how many...
Implement a class Student, including the following attributes and methods: Two public attributes name(String) and score...
Implement a class Student, including the following attributes and methods: Two public attributes name(String) and score (int). A constructor expects a name as a parameter. A method getLevel to get the level(char) of the student. score level table: A: score >= 90 B: score >= 80 and < 90 C: score >= 60 and < 80 D: score < 60 Example:          Student student = new Student("Zack"); student.score = 10; student.getLevel(); // should be 'D'. student.score = 60; student.getLevel(); //...
Create a Class to contain a customer order Create attributes of that class to store Company...
Create a Class to contain a customer order Create attributes of that class to store Company Name, Address and Sales Tax. Create a public property for each of these attributes. Create a class constructor without parameters that initializes the attributes to default values. Create a class constructor with parameters that initializes the attributes to the passed in parameter values. Create a behavior of that class to generate a welcome message that includes the company name. Create a Class to contain...
Visual Studio C# Create an application illustrating the following: Class definition Encapsulation Constructor Instantiation Inheritance Suggestions:...
Visual Studio C# Create an application illustrating the following: Class definition Encapsulation Constructor Instantiation Inheritance Suggestions: Simulation Calculation Interface apps
class Airplane – highlights -- modelID : String -planeType: String //”propeller” “jet” --fuelOnBoard : int --fuelCapacity:...
class Airplane – highlights -- modelID : String -planeType: String //”propeller” “jet” --fuelOnBoard : int --fuelCapacity: int //gallons …………... Assume getters and setters, toString(), constructor with parameters and constructor …………… Write lambdas using a standard functional interface to: a) Given a plane object and “propeller” or “jet” as an input, determine if the given plane matched the given type b) Output the plane description and “plane needs fuel” if fuel on board is less than 80% of fuel capacity c)...
C++ Consider a class Movie that information about a movie. The class has the following attributes:...
C++ Consider a class Movie that information about a movie. The class has the following attributes: • The movie name • The MPAA rating (for example, G, PG, PG-13, R) • Array of size 5 called Ratings, each index will hold the following. [0] The number of people that have rated this movie as a 1 (Terrible) [1] The number of people that have rated this movie as a 2 (Bad) [2] The number of people that have rated this...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT