![]() |
static struct initialization in a Class:: -- not my struct
I am would love to be able to initialize a struct statically in my
class, but the compiler seems to throw a fit when I do. I have something like // in h file class MyClass { private: static CK_INFO aStruct; }; // in .cpp file // yes, I know the strings must be blank padded MyClass::aStruct = {{1,0},"christian",0,"Whatever",{2,0}}; The struct looks like this: typedef struct CK_INFO { CK_VERSION cryptokiVersion; /* Cryptoki interface version number */ CK_CHAR manufacturerID[32]; /* blank padded */ CK_FLAGS flags; /* must be zero */ /* libraryDescription and libraryVersion are new for v2.0 */ CK_CHAR libraryDescription[32]; /* blank padded */ CK_VERSION libraryVersion; /* version of library */ } CK_INFO; error C2501: 'MyClass::info' : missing storage-class or type specifiers error C2371: 'info' : redefinition; different basic types I know this is propably an easy question, I am just not that familiar with static initializing in C++ |
Re: static struct initialization in a Class:: -- not my struct
christian.bongiorno@gmail.com wrote: > I am would love to be able to initialize a struct statically in my > class, but the compiler seems to throw a fit when I do. I have > something like > > // in h file > class MyClass { > > > private: > static CK_INFO aStruct; > }; > > // in .cpp file > // yes, I know the strings must be blank padded > MyClass::aStruct = {{1,0},"christian",0,"Whatever",{2,0}}; > > The struct looks like this: > > typedef struct CK_INFO { > CK_VERSION cryptokiVersion; /* Cryptoki interface version > number */ > CK_CHAR manufacturerID[32]; /* blank padded */ > CK_FLAGS flags; /* must be zero */ > > /* libraryDescription and libraryVersion are new for v2.0 */ > CK_CHAR libraryDescription[32]; /* blank padded */ > CK_VERSION libraryVersion; /* version of library */ > } CK_INFO; Try removing above CK_INFO > > error C2501: 'MyClass::info' : missing storage-class or type > specifiers > error C2371: 'info' : redefinition; different basic types > > I know this is propably an easy question, I am just not that familiar > with static initializing in C++ |
Re: static struct initialization in a Class:: -- not my struct
On 20 Sep 2006 11:06:33 -0700 in comp.lang.c++,
christian.bongiorno@gmail.com wrote, > static CK_INFO aStruct; >}; > >// in .cpp file >// yes, I know the strings must be blank padded >MyClass::aStruct = {{1,0},"christian",0,"Whatever",{2,0}}; CK_INFO MyClass::aStruct = {{1,0},"christian",0,"Whatever",{2,0}}; ^^^^^^^ |
| All times are GMT. The time now is 12:25 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.