How can we initialize the static string str in class 'a' below..
Code:#include<iostream> #include<string,h> class a { static char str[80]; }; int main() { }
How can we initialize the static string str in class 'a' below..
Code:#include<iostream> #include<string,h> class a { static char str[80]; }; int main() { }
You would say( globally ):
EDIT: Actually, I'm not so sure about what I wrote above. You could declare a public static function that would set the string.Code:char a::str[80] = "This is a string";
Last edited by GReaper; 02-28-2012 at 08:25 AM.
Devoted my life to programming...
GReaper is correct, but of course this should go in the source file, not the header file.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)