C++: use array of strings wrapped in namespace? -
Code> Namespace message ({int arr_sz = 3; Const char * msg [arr_sz] = {"blank", "blank", "blank"} ;sg [0] = "Welcome, blah blah string 1! \ N" ;sg [1] = "OK, bla bla bla .."; msg [2] = "etc.";}
The code inside works well inside a function But I do not know how to get an array from this, the namespace idea looks fine, but this The cheat lays down on three lines: error: type before expected constructor, destructor, or '=' token
Why can not I define the array inside the namespace, Do I need to do something before?
This is good because I can call it like printf (msg :: msg [1]). I just want to do what I say is wrong. Wrap my head around: (
You can arrange the array inside the namespace You can define:
// This is legal name location message {const char * msg [] = {"blank", "blank", "blank"}}}
You can not do that, there is a statement outside a function:
// This is a statement, it should be inside a function message [0 ] = "Welcome, little info from you! \ N ";
So to correct your code, just use the right string in the definition:
namespace message {const char * Msg [] = {"Welcome, get started with a little information from you! \ N "," OK, blah blah blah .. "," etc. "};}
Comments
Post a Comment