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();      
}
yoshi99
  • 109
  • 4

2 Answers2

3

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.

Community
  • 1
  • 1
Brian R. Bondy
  • 339,232
  • 124
  • 596
  • 636
  • 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 Sep 30 '10 at 19:06
1

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
  • 48,078
  • 23
  • 82
  • 145