Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- using namespace std;
- struct Al
- {
- int d;
- };
- Al operator + (Al &kill, Al &koll)
- {
- Al dill;
- dill.d = kill.d + koll.d;
- return dill;
- }
- template < typename T >
- T clo(T a, T b)
- {
- T c;
- c = a + b;
- return c;
- }
- template < class T, size_t size >
- class Te
- {
- private:
- T a1[size];
- public:
- Te()
- {
- for (int i=0; i < size; i++)
- {
- cout << endl << "Vvedite " << i + 1 << " chislo ";
- cin >> a1[i];
- }
- }
- void slog()
- {
- for (int i=0; i < size-1; i++)
- {
- a1[0] = a1[0] + a1[i + 1];
- }
- cout << endl << "Rezyltat clogenia= " << a1[0];
- }
- };
- int main()
- {
- int s1 = 7, s2 = 18;
- double s3 = 12.3, s4 = 56.23;
- cout << "Skladivaem chials 7 and 18";
- cout << endl << "Otvet=" << clo <int>(s1, s2);
- cout << endl;
- cout << "__________________________________________________________________________";
- cout << endl << endl;
- cout << "Skladivaem chials 12.3 and 56.23";
- cout << endl << "Otvet=" << clo <double >(s3, s4);
- cout << endl;
- cout << endl;
- cout << "__________________________________________________________________________";
- Te <int, 2> F;
- F.slog();
- cout << endl;
- cout << "__________________________________________________________________________";
- Al h;
- Al j;
- h.d = 17;
- j.d = 3;
- Al g;
- g = clo <Al>(h, j);
- cout << endl << h.d << "+" << j.d;
- cout << "=" << g.d << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement