#include <iostream>
using namespace std;
class Polygon{
float length, *width;
public:
Polygon(){}
Polygon(float l, float w){
length = l;
width = new float(w);
}
Polygon(const Polygon &N){
width = N.width;
length = N.length;
}
void modify(float f){
*width = f;
}
void display(){
cout<<"length: "<<length<<endl;
cout<<"width: "<<*width<<endl;
}
};
int main(){
Polygon one(5, 4), two = one;
cout<<"One\n";
one.display();
cout<<"\nTwo\n";
two.display();
cout<<"\nModifying two\n";
two.modify(6);
cout<<"\nOne\n";
one.display();
return 0;
}
Comments
Leave a comment