0
我得到了下面的代碼,希望換一組字符串很好地在一個命名空間:C++:使用包裝在命名空間中的字符串數組?
namespace msgs {
const int arr_sz = 3;
const char *msg[arr_sz] = {"blank", "blank", "blank" };
msg[0] = "Welcome, bla bla string 1!\n";
msg[1] = "Alright, bla bla bla..";
msg[2] = "etc.";
}
裏面的代碼在函數內部工作得很好,但我不知道如何從它返回一個數組。命名空間的想法LOOKS很好,但它返回最後三行: error: expected constructor, destructor, or type conversion before ‘=’ token
爲什麼我不能在命名空間內定義數組,我需要先做些什麼?
很高興,因爲我可以稱它爲如printf(消息::味精[1])等。我想這樣做,我不能環繞出了什麼問題:(我的頭
我在發佈之後發現了這個JUST,我忘記了我在嘗試修改它們之前初始化數組,只是想在這裏仔細檢查一下爲什麼我無法定義它。 – 2010-06-14 05:42:17