0
我们可以使用structure.element
来打印结构的元素。但我想一次打印完整的结构。如何在C++中打印结构?
有没有类似cout<<strucutre
的方法,就像我们可以在Python中打印列表或元组一样。
这就是我想要的:
struct node {
int next;
string data;
};
main()
{
node n;
cout<<n;
}
重载运算符<< –
一切你想知道:https://stackoverflow.com/questions/4421706/operator-overloading – NathanOliver
你有重载'std :: ostream&Operator <<(std :: ostream&,const node&)'操作符来执行此操作。 –