Created
June 23, 2016 15:16
-
-
Save kkabdol/ae887d46ce032f24f26f1ce9327e3ab5 to your computer and use it in GitHub Desktop.
explicit keyword
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template<class T> | |
| class Array { | |
| public: | |
| ... | |
| explicit Array(int Size); | |
| ... | |
| }; | |
| Array<int> a(10); | |
| Array<int> b(10); | |
| if (a == b[i]) ... // error! no way to | |
| // implicitly convert | |
| // int to Array<int> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More Effective C++ Item 5: Be wary of user-defined conversion functions