[英]strange overload = operator on some book, c-style?
I find some books which this kind of code:我找到了一些这类代码的书:
but if I try to compile somethings similar, it says that miss argument?但是如果我尝试编译类似的东西,它会说错过参数?
struct Test {
double offsetDetected = 0.0;
Test() {}
Test &operator=() // removed here
};
what's wrong, and why books write this way those stuff?怎么了,为什么书会这样写那些东西? c-style?
c风格?
This is C++, there's no "C style" for it.这是 C++,它没有“C 风格”。 The book you're citing has a typo.
你引用的书有错别字。 That's all.
就这样。 I doubt that you find some "books".
我怀疑你找到了一些“书”。 You found one book, I bet.
你找到了一本书,我敢打赌。 The assignment operator requires an argument, since it's a binary operator.
赋值运算符需要一个参数,因为它是一个二元运算符。
It is a binary operator.As the other asnwere mentioned it might have a typing error.它是一个二元运算符。正如其他人提到的那样,它可能有打字错误。
#include <iostream>
struct Test {
double offsetDetected = 0.0;
Test() {}
Test &operator=(const Test &obj); // removed here
};
int main() {
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.