static struct initialization in a Class:: -- not my struct

  • Thread starter christian.bongiorno
  • Start date
C

christian.bongiorno

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++
 
S

S S

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
 
D

David Harmon

On 20 Sep 2006 11:06:33 -0700 in comp.lang.c++,
(e-mail address removed) 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}};
^^^^^^^
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top