Create a class Car, which contains • Three data members i.e. carName (of string type), ignition (of bool type), and currentSpeed (of integer type) • A no-argument constructor to initialize all data members with default values • A parameterized constructor to initialize all data members with user-defined values • Three setter functions to set values for all data members individually • Three getter function to get value of all data members individually • A member function setSpeed( ) // takes integer argument for setting speed Derive a class named Convertible that contains • A data member top (of Boolean type) • A no-argument constructor to assign default value as “false” to top • A four argument constructor to assign values to all data-members i.e. carName, ignition, currentSpeed and top. • A setter to set the top data member up • A function named show() that displays all data member values of invoking object Write a main() function that instantiates objects of Convertible class and test the functionality of all its member functions.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Create a class Car, which contains
• Three data members i.e. carName (of string type), ignition (of bool type), and currentSpeed (of integer type)
• A no-argument constructor to initialize all data members with default values
• A parameterized constructor to initialize all data members with user-defined values
• Three setter functions to set values for all data members individually
• Three getter function to get value of all data members individually
• A member function setSpeed( ) // takes integer argument for setting speed
Derive a class named Convertible that contains
• A data member top (of Boolean type)
• A no-argument constructor to assign default value as “false” to top
• A four argument constructor to assign values to all data-members i.e. carName, ignition,
currentSpeed and top.
• A setter to set the top data member up
• A function named show() that displays all data member values of invoking object
Write a main() function that instantiates objects of Convertible class and test the functionality of
all its member functions.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images