Skip to content

Instantly share code, notes, and snippets.

@kkabdol
Created June 23, 2016 15:16
Show Gist options
  • Select an option

  • Save kkabdol/ae887d46ce032f24f26f1ce9327e3ab5 to your computer and use it in GitHub Desktop.

Select an option

Save kkabdol/ae887d46ce032f24f26f1ce9327e3ab5 to your computer and use it in GitHub Desktop.
explicit keyword
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>
@kkabdol
Copy link
Author

kkabdol commented Jun 23, 2016

More Effective C++ Item 5: Be wary of user-defined conversion functions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment