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?
This is C++, there's no "C style" for it. 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() {
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.