On Mon, Dec 04, 2023 at 11:46:45PM +0000, DLearner via Digitalmars-d-learn 
wrote:
[...]
> Basically, B corresponds to the whole record (and only a whole record
> can be read).
> But the task only requires Var1 and Var2, the last two fields on the record.
> By putting all the irrelevant fields into A, and defining B as above,
> program remains unpolluted with data it does not need.
[...]

Sounds like what you need is something like this:

        struct Record {
                struct UnimportantStuff {
                        ...
                }
                UnimportantStuff unimportant;

                struct ImportantStuff {
                        ...
                }
                ImportantStuff important;
        }

        ImportantStuff readData() {
                Record rec = readData(...); // read entire record
                return rec.important; // discard unimportant stuff
        }

        int main() {
                ...
                ImportantStuff data = readData(); // only important stuff 
returned
                processData(data);
                ...
        }


T

-- 
Let X be the set not defined by this sentence...

Reply via email to