标签:声明 ons oid operator style 标准库 member space include
#include <array> #include <iostream> using namespace std; struct Point { int x, y; }; ostream& operator<<(ostream& os, Point p) { os << ‘{‘ << p.x << ‘,‘ << p.y << ‘}‘; return os; } template<typename T, int N> void print(array<T, N>& a) { for (int i = 0; i != N; ++i) cout << a[i] << ‘\n‘; } int main() { array<Point, 3> points{ {{1,2},{3,4},{5,6}} }; print<Point,3>(points); return 0; }
标准库array声明为:
template<typename T, size_t N> struct array{ T elem[N]; //other member functions };
标签:声明 ons oid operator style 标准库 member space include
原文地址:https://www.cnblogs.com/lhb666aboluo/p/12724552.html