Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Ponizej jest prosta klasa.
- #include <iostream>
- #include <fstream>
- #include <functional>
- #include <algorithm>
- #include <list>
- #include <vector>
- #include <map>
- #include <iterator>
- #include <string>
- #include <cstring>
- using namespace std;
- class Slowo {
- string s;
- public:
- Slowo( const char* c ) : s( c ? c : "" ) {}
- Slowo(initializer_list<const char*> arg)
- {
- char *tmp;
- for(auto it = arg.begin(); it != arg.end(); ++it)
- {
- tmp = it;
- tmp++;
- }
- s = tmp;
- }
- };
- int main()
- {
- Slowo s{'a', 'b', 'c'};
- return 0;
- }
- // Zdefiniuj dla tej klasy konstruktor, ktory bedzie miec argument typu initialization_list<const char*>
- // i utworz (w programie) obiekt z przykladowa klasa, wykorzystujaca odpowiedni typ inicjalizacji, taki
- // ktory wybierze ten wlasnie konstruktor.
- // Dopisz w klase operator konwersji na typ unsigned i dzialajacy tak, ze bedzie zwracal
- // wartosc bedaca dlugoscia obiektu s. Zademonstruj dzialanie na jakims przykladzie.
- // Dopisz tez konstruktor z argumentem typu unsigned taki, ze bedzie zamienial
- // podana wartosc na string i zainicjalizuj (nie przypisz) skladowa s. W tym celu
- // polecam uzycie funkcji to_string. Zademonstruj, ze (taka konwersja) dziala.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement