Skip to content

Instantly share code, notes, and snippets.

@sprintr
Created May 22, 2013 15:20
Show Gist options
  • Save sprintr/5628430 to your computer and use it in GitHub Desktop.
Save sprintr/5628430 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
using namespace std;
class Circle {
private:
double radius;
string color;
public:
Circle(double aradius = 1.0, string acolor = "red") {
radius = aradius;
color = acolor;
}
double getradius() {
return radius;
}
string getColor() {
return color;
}
double getarea() {
return radius * radius * 3.14;
}
};
int main() {
Circle c1(2.0, "blue");
Circle c2(2.0);
Circle c3;
cout << "Area of c1 = " << c1.getarea() << endl;
cout << "Area of c2 = " << c2.getarea() << endl;
cout << "Area of c3 = " << c3.getarea() << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment