Question
Write a complete C++ program that creates an Alligator class and uses objects of this class. The Alligator class consists of following components. Properties (using
Write a complete C++ program that creates an Alligator class and uses objects of this class. The Alligator class consists of following components.
Properties (using public access modifier):
weight: double
num_leg: int
age: double
Constructors:
Blank (no-argument) constructor: the constructor that has no parameter
Standard constructor: the constructor with the same number of parameters as properties.
Methods:
to Print(): no return, print the name and current value of every property.
swim(): no return, describe how the alligator swims using an output statement, for example, it swim slowly after a meal.
The main() function should be placed below the Alligator class, inside the same source file as the Alligator class.
In the main() function, do the following actions:
Create two Alligator objects, one from the no-argument constructor, and another from the standard constructor.
For the latter object from the standard constructor, a value should be read from the user with proper prompts for every property. At the end, call every method from each object.
For both objects, change every property's value using assignment statements, with values read from the user. Call every method from each object one more time.
Step by Step Solution
3.40 Rating (153 Votes )
There are 3 Steps involved in it
Step: 1
include using namespace std class Alligator private double weight int numleg double age pub...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started