Question
4. Create a C++ class named classA that will have and 3 instance global variables, 1 static global variable, 3 methods, and 2 constructors as
4. Create a C++ class named classA that will have and 3 instance global variables, 1 static global variable, 3 methods, and 2 constructors as described below:
3 instance global variables represent the width and length of a rectangle and the radius of a circle. They are not initialized.
1 static global variable represents the value of PI. It is initialized by the value of 3.1415926.
All these variables are double.
The 1st constructor has no parameter. When it is called, it will initialized 3 instance global variables with 3 different but meaningful values. That is, these values should be greater than zero.
The 2nd constructor has 3 parameters. When it is called, it will initialized 3 instance global variables with 3 different but meaningful values assigned to its parameters. That is, it is classed as "pass-by-value" and the values initializing 3 instance global variables must be greater than zero.
The 1st method is named funA that is an instance method and has no parameters and a returned value. The data type of the returned type is double. The method funA will calculate the area of a rectangle and return the area as the returned value.
The 2nd method is named funcB that is an instance method and has no parameters and has no returned value. The method funB will calculate the area of a circle and print the result
The 3rd method is the main method of this class. In the main method, creating two instances by calling two different constructors, and then call funcA and funcB.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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