-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
关于c++ primer 书籍英文版662页,中文版的587页 #49
Comments
手头没有纸质书,请告知一下第几章的第几节。 另外, 贴的代码能否保持完整(即贴到编译器可以通过编译那种)? |
#include using std::string; class test{ int main()
} |
更多这样的例子请参考:http://stackoverflow.com/questions/22714859/type-inference-for-stdinitializer-list 但注意,只有 不过这也取决于 编译器 本身的优化。譬如:在 VS 2013 里, |
其中有一个Blob articles = {"a","an","the"}//为何不会因为两步隐性类转换发生错误const char*到string以及std::initializer_list到Blob?
include
include
using std::string;
class test{
public:
test(std::initializer_list il) {}
test(string s) {};
};
int main()
{
test t = {"xyz"}; //通过编译
test a = "xyz"; //无法通过编译
return 0;
}
为什么会如此?
The text was updated successfully, but these errors were encountered: