Suppose a class named Circle is being written. A Circle has two private data mem
ID: 3566265 • Letter: S
Question
Suppose a class named Circle is being written. A Circle has two private data members: mCenter which is a Point object and represents the center of the circle; mRadius is a double and represents the radius of the circle.
Write the code for a constructor which has no arguments (a constructor with no arguments is called the default constructor ). The default constructor shall initialize mCenter so the center of the circle is at (0, 0). The constructor shall initialize mRadius so the radius of the circle is 0.
Continuing from the previous exercise. Write a second constructor that has two input arguments : pCenter is a Point object and is to be used to initialize mCenter; pRadius is a double and is to be used to initialize mRadius.
Explanation / Answer
For both answers make sure to erase all previous coding.
For the first part:
Circle::Circle(){
mCenter = Point (0,0);
mRadius = 0;
}
For the second part:
Circle::Circle(Point pCenter, double pRadius){
mCenter=pCenter;
mRadius=pRadius;
}
Also make sure to rate this 5 stars!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.