Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Osoba
- {
- friend istream& operator>>(istream&, Osoba&);
- friend ostream& operator<<(ostream&, const Osoba&);
- string imie;
- string nazwisko;
- public:
- Osoba() : imie(""), nazwisko("") {}
- Osoba(string, string);
- };
- Osoba::Osoba(string name1, string name2) : imie(name1), nazwisko(name2) {}
- istream& operator>>(istream& is, Osoba& obj)
- {
- string imie;
- string nazwisko;
- is >> imie >> nazwisko;
- obj = Osoba(imie, nazwisko);
- return is;
- }
- ostream& operator<<(ostream& os, const Osoba& obj)
- {
- os << obj.imie << ' ' << obj.nazwisko;
- return os;
- }
- int main()
- {
- Osoba nowa_osoba;
- cin >> nowa_osoba;
- cout << nowa_osoba;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement