Click here to Skip to main content
15,899,679 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Converting hex string to hex number? Pin
Zac Howland2-Aug-06 6:54
Zac Howland2-Aug-06 6:54 
QuestionAutomated MS Word and VC++ [modified] Pin
georgekjolly2-Aug-06 6:12
georgekjolly2-Aug-06 6:12 
AnswerRe: Automated MS Word and VC++ Pin
DaTxomin2-Aug-06 13:45
DaTxomin2-Aug-06 13:45 
GeneralRe: Automated MS Word and VC++ Pin
georgekjolly2-Aug-06 17:35
georgekjolly2-Aug-06 17:35 
QuestionNetUserGetInfo Problems - PLZ Help Pin
Programm3r2-Aug-06 5:21
Programm3r2-Aug-06 5:21 
QuestionRe: NetUserGetInfo Problems - PLZ Help Pin
David Crow2-Aug-06 5:53
David Crow2-Aug-06 5:53 
QuestionSize of an empty class Pin
Sarath C2-Aug-06 4:46
Sarath C2-Aug-06 4:46 
AnswerRe: Size of an empty class Pin
Zac Howland2-Aug-06 5:15
Zac Howland2-Aug-06 5:15 
Sarath. wrote:
1. Why a size of an empty class is 1 byte?


Because the standard requires it to be so. Basically, it is so you avoid problems where you try to allocate 0 bytes of memory (ever try to do int* pi = new int[0]?). If an empty class is always at least 1 byte, then you can't have that problem.

Sarath. wrote:
2. if this code executes, again the size of class is 1 byte (padding not occuring even padding size is 4)


The padding for characters is 1 byte. If that is all that is in your class, then it won't bother padding it since it is almost guaranteed to be placed on a byte boundary.

Sarath. wrote:
3. for this code it will print 8 bytes as size (default padding 4 bytes)


This actually occurs because the compiler packs extra characters for you (if you use pragma pack, you avoid this). Since you have more than just your character now, it places enough memory for your class to end on a double word boundary. This makes it more efficient if you declare an array of these objects since the integer values will be guaranteed to be on the proper boundaries in memory.

If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week

Zac

GeneralRe: Size of an empty class Pin
Sarath C2-Aug-06 5:24
Sarath C2-Aug-06 5:24 
GeneralRe: Size of an empty class Pin
Zac Howland2-Aug-06 5:45
Zac Howland2-Aug-06 5:45 
GeneralRe: Size of an empty class Pin
Sarath C2-Aug-06 18:59
Sarath C2-Aug-06 18:59 
AnswerRe: Size of an empty class [modified] Pin
prasad_som2-Aug-06 20:56
prasad_som2-Aug-06 20:56 
GeneralRe: Size of an empty class Pin
Zac Howland3-Aug-06 3:28
Zac Howland3-Aug-06 3:28 
AnswerRe: Size of an empty class Pin
David Crow2-Aug-06 5:51
David Crow2-Aug-06 5:51 
QuestionAnchor a dialog to another dialog Pin
NYTSX2-Aug-06 4:03
NYTSX2-Aug-06 4:03 
AnswerRe: Anchor a dialog to another dialog Pin
Ravi Bhavnani2-Aug-06 4:07
professionalRavi Bhavnani2-Aug-06 4:07 
GeneralRe: Anchor a dialog to another dialog Pin
Sarath C2-Aug-06 4:53
Sarath C2-Aug-06 4:53 
GeneralRe: Anchor a dialog to another dialog Pin
NYTSX2-Aug-06 5:04
NYTSX2-Aug-06 5:04 
GeneralRe: Anchor a dialog to another dialog Pin
Sarath C2-Aug-06 5:07
Sarath C2-Aug-06 5:07 
GeneralRe: Anchor a dialog to another dialog Pin
Ravi Bhavnani2-Aug-06 5:08
professionalRavi Bhavnani2-Aug-06 5:08 
QuestionMicrosft Visual Studio string tables with Similar Strings Pin
Christopher Stratmann2-Aug-06 3:50
Christopher Stratmann2-Aug-06 3:50 
AnswerRe: Microsft Visual Studio string tables with Similar Strings Pin
Ravi Bhavnani2-Aug-06 4:09
professionalRavi Bhavnani2-Aug-06 4:09 
GeneralRe: Microsft Visual Studio string tables with Similar Strings Pin
Christopher Stratmann2-Aug-06 4:14
Christopher Stratmann2-Aug-06 4:14 
AnswerRe: Microsft Visual Studio string tables with Similar Strings Pin
Ravi Bhavnani2-Aug-06 4:21
professionalRavi Bhavnani2-Aug-06 4:21 
GeneralRe: Microsft Visual Studio string tables with Similar Strings Pin
Christopher Stratmann2-Aug-06 4:29
Christopher Stratmann2-Aug-06 4:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.