-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy patharray.cpp
More file actions
28 lines (23 loc) · 877 Bytes
/
array.cpp
File metadata and controls
28 lines (23 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "array.h"
using namespace std;
// Написать шаблонные функции:
// 1. operator + (реализация внутри класса)
// 2. operator * (вектор на скаляр и скаляр на вектор; реализация вне класса)
// 3. Нахождение среднего для двух векторов (реализация вне класса)
ostream& operator <<(ostream& os, const Vector3d& v) {
return os << "{ " << v[0] << ", " << v[1] << ", " << v[2] << " }";
}
template<size_t Dimensions>
ostream& operator <<(ostream& os, const Vector<Dimensions>& v) {
os << "{ " << v[0];
for (size_t i = 1; i < Dimensions; i++)
os << ", " << v[i];
return os << " }";
}
int main() {
Vector<12> v1;
v1[1] = v1[2] = 54;
Vector<12> v2 = v1;
cout << v2 << endl;
return 0;
}