I don't think i'm the one who can give an advice about "best practices"...
Anyway , what do you mean "I can of course access the structure directly" ? Maybe i'm missing something but it seems like you're confusing type's declaration with a type's instance. You've got a structure's declaration placed in a header file : that's it , this way you can do this :
// in wherver header/source file the readheader.h is included //
headerInfo newHeaderInfoObject ;
newHeaderInfoObject.numberOfSamples = 10 ;
// ...
// etc.
// in wherver header/source file the readheader.h is included //
headerInfo newHeaderInfoObject ;
newHeaderInfoObject.numberOfSamples = 10 ;
// ...
// etc.
To copy to clipboard, switch view to plain text mode
However , If you had the headerInfo declaration placed within a readHeader class :
// in wherver header/source file the readheader.h is included //
readHeader::headerInfo newHeaderInfoObject ; // if headerInfo declaration is placed in a PRIVATE section : ERROR
readHeader::headerInfo newHeaderInfoObject ; // if headerInfo declaration is placed in a PROTECTED section : ERROR
readHeader::headerInfo newHeaderInfoObject ; // if headerInfo declaration is placed in a PUBLIC section : OK
// in wherver header/source file the readheader.h is included //
readHeader::headerInfo newHeaderInfoObject ; // if headerInfo declaration is placed in a PRIVATE section : ERROR
readHeader::headerInfo newHeaderInfoObject ; // if headerInfo declaration is placed in a PROTECTED section : ERROR
readHeader::headerInfo newHeaderInfoObject ; // if headerInfo declaration is placed in a PUBLIC section : OK
To copy to clipboard, switch view to plain text mode
But , getting back to "I can of course access the structure directly" : since you've placed "headerInfo p_hdrinfo" in the PRIVATE section , there is no way you can access it directly .Isn't it the reason you've created methods for accessing it ?^^ So , depending on how you're gonna use the readHeader class in your application's data architecture , you'll probably have to place it in either PRIVATE or PROTECTED sections...
Bookmarks