Create a circle class(circle.cpp). main.cpp circle.h Forthis homework you will h
ID: 3760064 • Letter: C
Question
Create a circle class(circle.cpp).
main.cpp
circle.h
Forthis homework you will hove to impenent a eircle" dlass You are given a main For this homework you will have to implement a "circle" class. You are given a main source file and the circle class definition file. The following members are part of the "circle" class. radius: radius of the circle circle): default constructor circle(float r): constructor which will set the radius circle(const circle &obj;): copy constructor void setRadius(float): method for setting radius float getRadius(void): Returns radius of circle float getArea(void): Returns area of circle float getCircumference(void): Returns circumference of circle Once you have implemented the circle class and all of its methods, the output of the main function should look like Area of c1: 12.5664 Circunference of c2: 25.1327 Radius of c3: 10 Radius of c4: 10 tin@tin-laptop:-/Dropbox/EGRE-246/spring_2014/assignnents/hw6sExplanation / Answer
#include <iostream>
#include <math.j>
using namespace std;
class circle{
public:
circle(){
radius = 0.0;
}
circle(float r){
radius = r;
}
circle(const circle &obj){
this.radius = obj.radius;
}
void setRadius(float r){
radius = r;
}
float getRadius(){
return radius;
}
float getArea(){
return M_PI*radius*radius;
}
float getCircumference(){
return 2*M_PI*radius;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.