Created
May 22, 2013 15:20
-
-
Save sprintr/5628430 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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