Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3842246
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:45:57+00:00 2026-05-19T15:45:57+00:00

I have a program that stores it’s information in an XML file. This file

  • 0

I have a program that stores it’s information in an XML file. This file is read in and a corresponding object model is created. The object model has a tree hierarchy. The object type we’ll call BigHierarchy.

Now, my program has a feature that allows the user to import another file. So, when he selects the file he wishes to import I read in that file and construct an another object of type BigHierarchy to represent the import file. So now I have the original BigHierarchy object and the new one I need to merge. Since it’s a hierarchy, some of the data is private and not accessible.

How do I go about merging the import object with the original object if I don’t have access to the private data? What technique should I use? Should the leaf nodes friend the higher ups so I have full visibility from the top? Should I add overload all the leafs and overload plus operator so I can merge everything or should I make member functions in each level that copies all the private data. Every option seems messy. How do I go about this in the best way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T15:45:58+00:00Added an answer on May 19, 2026 at 3:45 pm

    To get to the exact design you need to first define what would be your merge strategy in case there is a conflict between private members at their most atomic level.

    1. Overwrite with latest
    2. Keep original
    3. Merge the changes

    If you go with approach 1, then you will overwrite the existing BigHierarchy with new one. In this case you will need access methods which allow setting the private members. This way encapsulation will not get affected.

    If you choose approach 2, then you will not be touching the private members at all.

    For option 3, it would be wise to provide a merge function to all private members if that is possible. Rather I would mandate my objects to implement merge and invoke it passing the new object while doing merge.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a program that stores booking information in a text file in
I have a C program that stores some object in java store using JNI.
I have a client requesting a very simple program that stores basic information that
I have a program in C++ that has a BYTE array that stores some
I have program that has a variable that should never change. However, somehow, it
I have a program that reads from a file that grabs 4 bytes from
I have a program that stores user projects as databases. Naturally, the program should
If I made a program that stores strings on a text file using the
I am trying to make a program that stores selected file's (specifically: executable's) contents
I have a program that sends data to a web service and stores the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.