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 Answers 2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.
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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.