Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Operationv2 {
- int a;
- int b;
- public:
- Operationv2( const int a, const int b )
- : a(a), b(b) {}
- Operationv2()
- : Operationv2( 0, 0 ) {}
- void swap( ) {
- std::swap( a, b );
- }
- friend istream & operator >> ( istream & is, Operationv2 & op ) {
- is >> op.a >> op.b;
- return is;
- }
- friend ostream & operator << ( ostream & os, const Operationv2 & op) {
- os << "A = " << op.a << "\n"
- << "B = " << op.b << std::endl;
- return os;
- }
- };
- int main() {
- Operationv2 op;
- cout << "Enter value for a and b" << std::endl;
- cin >> op;
- cout << op;
- op.swap( );
- cout << op;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement