views:

50

answers:

2

Hi am new to Visual C++, Could Someone please explain what ConfParams() declared in a structure does

__declspec(align(BYTE)) struct ConfParams
{
    BOOL m_timeout;
    DOUBLE m_caution;
    ConfParams();      
}
+2  A: 

Could Someone please explain what ConfParams() declared in a structure does

It's a constructor declaration.

In C++ other than default accessibility level struct and class are equivalent. struct by default has public members, class by default has private members.


I'm not clear why your subject references __declspec but if that's what you want to know about see here.

Member functions have no alignment only the data is affected.

Brian R. Bondy
Thanks, I was confused in seeing a constructor being defined in a struct. Wasn't quite sure if it had something to do with __declspec.
yoshi99
+1  A: 

google says

http://msdn.microsoft.com/en-US/library/83ythb65%28v=VS.80%29.aspx

"Use __declspec(align(#)) to precisely control the alignment of user-defined data (for example, static allocations or automatic data in a function)"

It will make the compiler start every instance on a byte boundary. Without it instances would have been aligned on the machines natural boundary - which would probably be 4 bytes.

pm100