Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // friend functions
- // #include "stdafx.h" // serve per VisualStudio
- #include <iostream>
- using namespace std;
- class Myclass
- {
- int a, b;
- public:
- Myclass (int i, int j) { a = i; b = j; }
- friend int prodotto(Myclass);
- };
- int prodotto(Myclass temp)
- {
- return ( temp.a* temp.b );
- }
- int main()
- {
- Myclass A(5, 3);
- cout << prodotto(A); //il risultato รจ 15
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement