0
如何在C++ 11中默認初始化成員數組?看來我必須提供一個界限。對於數組成員C++的類默認初始值設定程序11
class Example {
const char* num2letter[10]{" ", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
};
編譯好。但是,如果我忽略綁定,然後我得到一個編譯器錯誤:
error: too many initializers for 'const char* [0]' const char* num2letter[]{" ", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
爲什麼編譯器不能推斷綁定爲通常它可以爲本地數組定義使用集合初始化?
的重複(HTTP ://stackoverflow.com/questions/29593207/what-is-the-reason-for-not-being-able-to-deduce-array-size-from-initializer-stri) –