Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. # include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class line
  6. {
  7.     int x1;
  8.     int x2;
  9.     int len;
  10.  
  11. public:
  12.     friend ostream& operator<< (ostream& out, const line ln);
  13.     friend istream& operator>>(istream& inp, line& ln);
  14.     line(int a);
  15. };
  16.  
  17. ostream& operator<< (ostream& out, const line ln)
  18. {
  19.     for (int i = 0; i < ln.len; ++i)
  20.         out << "*";
  21.  
  22.     out << "\n";   
  23.     return out;
  24. }
  25.  
  26. istream& operator >> (istream& inp, line& ln)
  27. {
  28.     inp >> ln.len;
  29.     return inp;
  30. }
  31.  
  32. line::line(int a) {
  33.     len = a;
  34.     x1 = 5;
  35.     x2 = 8;
  36. }
  37.  
  38.  
  39.  
  40. int main()
  41.  
  42. {
  43.     setlocale(LC_ALL, "Russian");
  44.     cout << "Введите длину линии:\n";
  45.     int l;
  46.     cin >> l;
  47.     line L1(l);
  48.     cin >> L1;
  49.     cout << L1;
  50.     system("pause");
  51.     return 0;
  52.     cin.ignore(); cin.get();
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement