The C++ Standard says that "=" , "()" , "[]" should be non static member function.
Why it is specified in this way ? Why do we need to define standard in such a manner ?
I don't know what the standards committee was thinking, but these operators aren't much use if they are not operating on the object itself.
You also get into trouble if "anything" can be used for operator()
or operator[]
, since they are also used in conventional code. If you don't need an object to operate on [and thus select the correct operator through], it gets messy to figure out which operator[]
to use.
The operator=
is even more so: What are you assigning, if not an object? It makes absolutely no sense to do that on anything but an object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With