[英]C++ Override >> operator
I am writing a program where an arbitrarily large number is represented by a doubly linked list where a node in this list represents one digit of the large number. 我正在编写一个程序,其中用一个双向链接列表表示任意大的数字,其中该列表中的节点代表该大数字的一位。
As part of the problem, I need to override the '>>' operator so that when I type in a large number, the program takes the number and creates a big_number class using that number. 作为问题的一部分,我需要重写'>>'运算符,以便当我键入大数字时,程序将使用该数字并使用该数字创建big_number类。 (big_number class is the doubly linked list representing a large number.) (big_number类是代表较大数字的双向链表。)
My Override: 我的替代:
istream& >> operator(istream& in, big_number& n)
{
//Code I need to write
return in;
}
This line: 这行:
istream& >> operator(istream& in, big_number& n)
should be either 应该是
istream& operator>>( istream& in, big_number& n )
or 要么
auto operator>>( istream& in, big_number& n )
-> istream&
In your later SO postings, please include also your build command and error messages. 在以后的SO帖子中,还请包括您的构建命令和错误消息。
In passing, regarding terminology, this is an overload , not an override . 顺便说一句,关于术语,这是一个重载 ,而不是覆盖 。 The latter is what you have when you override a base class' virtual member function. 后者是您重写基类的虚拟成员函数时所拥有的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.