Write C++ code and make it compile and run showing how to use: abstract data type const class constructor You can write a single program or multiple programs to demonstrate the above, I just need to see how each is used and how it runs.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Write C++ code and make it compile and run showing how to use:

abstract data type

const

class constructor

You can write a single program or multiple programs to demonstrate the above, I just need to see how each is used and how it runs.

 

Expert Solution
Algorithm

Step-1: Start
Step-2: Define a class Animal as an abstract data type with a pure virtual function makeSound()
Step-3: Define a class Dog that inherits from Animal and has a private string variable name
Step-4: Implement the Dog constructor that takes a string argument to initialize the name variable
Step-5: Implement the makeSound() function in the Dog class to print the name followed by "barks!" to the console
Step-6: Define a constant integer MAX_DOGS with a value of 3
Step-7: Create three Dog objects using the Dog constructor and assign them to variables dog1, dog2, and dog3
Step-8: Create an array of Animal pointers called animals with a size of MAX_DOGS
Step-9: Assign each dog object to a position in the animals array
Step-10: Loop through the animals array using a for loop with the loop variable i ranging from 0 to MAX_DOGS-1
Step-11: Call the makeSound() function on each animal using the arrow operator
Step-12: Stop

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education