Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- #define pi 3.14
- #define N 4
- using namespace std;
- class kolo {
- float R, x, y, s;
- public :
- kolo() {
- }
- kolo(float a, float b, float c) : x(a), y(b), R(c) {
- cout << "using a list initialization constructor" << endl;
- }
- kolo(const kolo &src) {
- x = src.x;
- y = src.y;
- R = src.R;
- cout << "using the copy constructor" << endl;
- }
- void set(string c) {
- cout << "Enter kolo " << c << ": ";
- cout<<"R = ";
- cin>>R;
- cout<<"X coordinate = ";
- cin>>x;
- cout<<"Y coordinate = ";
- cin>>y;
- }
- void show(string c) {
- cout << "Kolo " << c << ": ";
- cout<<"R = "<<R<<endl;
- cout<<"X coordinate = "<<x<<endl;
- cout<<"Y coordinate = "<<y<<endl;
- cout<<"S = "<<S()<<endl;
- }
- float S() {
- s = pi*R*R;
- return s;
- }
- void analis(float a) {
- S();
- if(s >= a) {
- cout<<"S = "<<s<<" > "<<a<<endl;
- } else {
- cout << "Circle s < " << a << endl;
- }
- }
- friend kolo operator ++ ( kolo &a) {
- ++a.R;
- ++a.x;
- ++a.y;
- return a;
- }
- friend bool operator >= ( kolo &a, kolo &b) {
- if(a.s >= b.s) {
- return true;
- } else {
- return false;
- }
- }
- };
- int main() {
- int i;
- float p;
- bool a;
- kolo c1;
- c1.set("c1");
- c1.show("c1");
- kolo c2(0,0,4);
- c2.show("c2");
- kolo c3 = c2;
- c3.show("c3");
- ++c2;
- c2.show("c2");
- kolo c4 = c2;
- c4.show("c4");
- cout<<"c4 >= c1"<<endl;
- a = c4 >= c1;
- cout<<boolalpha<<a<<endl;
- kolo x[N];
- for(i=0; i<N; i++) {
- x[i].set("x");
- }
- cout<<"Enter P :";
- cin>>p;
- for(i=0; i<N; i++) {
- x[i].analis(p);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment