Advertisement
Guest User

Untitled

a guest
May 27th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. // Ponizej jest prosta klasa.
  2. #include <iostream>
  3. #include <fstream>
  4. #include <functional>
  5. #include <algorithm>
  6. #include <list>
  7. #include <vector>
  8. #include <map>
  9. #include <iterator>
  10. #include <string>
  11. #include <cstring>
  12.  
  13. using namespace std;
  14.  
  15. class Slowo {
  16. string s;
  17. public:
  18. Slowo( const char* c ) : s( c ? c : "" ) {}
  19.  
  20. Slowo(initializer_list<const char*> arg)
  21. {
  22. char *tmp;
  23. for(auto it = arg.begin(); it != arg.end(); ++it)
  24. {
  25. tmp = it;
  26. tmp++;
  27. }
  28. s = tmp;
  29. }
  30. };
  31.  
  32. int main()
  33. {
  34. Slowo s{'a', 'b', 'c'};
  35.  
  36. return 0;
  37. }
  38.  
  39. // Zdefiniuj dla tej klasy konstruktor, ktory bedzie miec argument typu initialization_list<const char*>
  40. // i utworz (w programie) obiekt z przykladowa klasa, wykorzystujaca odpowiedni typ inicjalizacji, taki
  41. // ktory wybierze ten wlasnie konstruktor.
  42. // Dopisz w klase operator konwersji na typ unsigned i dzialajacy tak, ze bedzie zwracal
  43. // wartosc bedaca dlugoscia obiektu s. Zademonstruj dzialanie na jakims przykladzie.
  44. // Dopisz tez konstruktor z argumentem typu unsigned taki, ze bedzie zamienial
  45. // podana wartosc na string i zainicjalizuj (nie przypisz) skladowa s. W tym celu
  46. // polecam uzycie funkcji to_string. Zademonstruj, ze (taka konwersja) dziala.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement