1.
2.
#include <iostream>
using namespace std;
class Rectangle
{
public:
void set_l(int length)
{
_length = length;
}
void set_w(int width)
{
_width = width;
}
int get_l()
{
return _length;
}
int get_w()
{
return _width;
}
void show()
{
cout<<"周长:"<<(_length+_width)*2<<endl;
cout<<"面积:"<<_length*_width<<endl;
}
private:
int _length;
int _width;
};
int main()
{
Rectangle d1;
d1.set_l(2);
d1.set_w(3);
d1.show();
int l = d1.get_l();
int w = d1.get_w();
cout<<l<<endl;
cout<<w<<endl;
return 0;
}