2
Запрет функции, принимающей const std :: string & от принятия 0
Стоит тысячи слов: #include<string> #include<iostream> class SayWhat { public: SayWhat& operator[](const std::string& s) { std::cout<<"here\n"; // To make sure we fail on function entry std::cout<<s<<"\n"; return *this; } }; int main() { SayWhat ohNo; // ohNo[1]; // Does not compile. Logic prevails. ohNo[0]; // you didn't! this compiles. return 0; …