举个例子:
- #include<iostream>
- using namespace std;
- class cylinder
- {
- friend istream operator>>(istream& is,cylinder &cy);
- public:
- inline double square()
- { return length*(width+height)*2+width*height*2; }
- inline double volume()
- { return length*width*height; }
- private:
- double length;
- double width;
- double height;
- };
- istream operator>>(istream is,cylinder &cy)
- {
- cout<<"input length:"<<endl;
- is>>cy.length;
- cout<<"input width:"<<endl;
- is>>cy.width;
- cout<<"input height:"<<endl;
- is>>cy.height;
- return is;
- }
- int m