函数内静态常量的用法 请高手指点
一个如下的函数,返回一个对应索引的字符串:
const char* msg_to_user(int num_tries)
{
static const char* user_msgs[] = {
"Go on, make a guess. ",
"Oops! Nice guess but not quite it.",
"Hmm. Sorry. Wrong again.",
"Ah, this is harder than it looks, no?",
"It must be getting pretty frustrating by now!"
};
return user_msgs[ num_tries ];
}
请问,为什么user_msgs要用静态常量。为什么不定义为:
const char* user_msgs[] = { ...
或者
char* user_msgs[] = { ...