-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
关于set 和map的比较操作符重载问题 #114
Comments
friend 的原型在类中出现,但是貌似友元函数不是成员函数吧,应该不会出现重定义的问题。 |
不会重定义。类内的是非模板函数,它与函数模板不对应。 但这个设计会导致类外的 |
我想我们可以把 MyTinySTL 的所有比较运算符改成友元。虽然这和标准库不一致,但可能更好。 |
谢谢解答!对类模板的友元了解的不是很透彻,请教一下大佬这里的 |
是的,此处的 |
friend bool operator==(const set& lhs, const set& rhs) { return lhs.tree_ == rhs.tree_; } friend bool operator< (const set& lhs, const set& rhs) { return lhs.tree_ < rhs.tree_; }
set.h第199行和200行
已经在类内定义了比较操作符,在类外又定义了一次,这样不会出现重定义的问题吗
The text was updated successfully, but these errors were encountered: