Print Friendly and PDF
#include<iostream> 
using namespace std; 
class Shape 
{ 
public: 
float length; 
float width; 
public:Shape() 
{ 
length=0; 
width=0; 
} 
void setlength(float l) 
{ 
length=l; 
} 
void setwidth(float w) 
{ 
width=w; 
}
float getlength() 
{ 
return length; 
} 
float getwidth() 
{ 
return width; 
} 
Shape operator+=(const Shape& c) 
{ 
this->length+= c.lenght; 
this->width+=c.width; 
return*this; 
} 
}; 
int main() 
{ 
Shape c1,c2,c3; 
c1.setlength(10); 
c2.setlength(20); 
c1.setwidth(30); 
c2.setwidth(40); 
c1+=c2; 
cout<<"len is"<<c1.getlength(); 
}
zubairsaif

Zubair saif

A passionate writer who loves to write on new technology and programming

Post A Comment:

0 comments: