如何避免创建“typedef Point* pPoint;” 对于“<<”重载函数中的第二个参数?
这样做的正确方法是什么?我在哪里可以阅读更多关于它的信息?
#include <iostream>
using namespace std;
typedef float Point[3];
typedef Point* pPoint;
ostream & operator << (std::ostream &os, const pPoint & p )
{
int size = sizeof(p);
for (int i=0; i<size; i++)
{
os << "[" << p[i][0] << "," << p[i][2] << "," << p[i][2] << "]" << endl;
}
return os;
}
int main() {
Point corners[8] = {
{ 1, -1, -5},
{ 1, -1, -3},
{ 1, 1, -5},
{ 1, 1, -3},
{-1, -1, -5},
{-1, -1, -3},
{-1, 1, -5},
{-1, 1, -3}
};
cout << "Point:" << corners<< endl;
return 0;
}