Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So, you are reading the information into the <code>Customer</code> object in the <code>first</code> variable, and then you throw this away with <code>first = first1</code>. (or <code>first2</code>, <code>first3</code>).</p> <p>Later you do the same thing with <code>temp</code> and <code>temp1</code> (or <code>temp2</code>, <code>temp3</code>).</p> <p>I think you misunderstood the meaning of the <code>=</code> operator. It does not change the class of the existing <code>first</code> object to the class of <code>first1</code>, but it switches the pointer in the variable from the existing object to another object.</p> <p>Before:</p> <pre><code> .------------. first -----&gt; | Customer | '------------' .------------. first1 ----&gt; | Account1 | | | '------------' </code></pre> <p>After:</p> <pre><code> .------------. first | Customer | \ '------------' \ \ .------------. '---&gt; | Account1 | first1 ----&gt; | | '------------' </code></pre> <p>All the information in the <code>Customer</code> object is now away. (The same applies in the other account types, and for <code>temp</code> later.)</p> <p>It looks like you have to do one of these:</p> <ul> <li><p>When deciding which account type to use, you have to copy the data to your account.</p> <p>You could use a copy constructor for this.</p></li> <li><p>change your file format to contain the account type first, and create an object of the right type at the start.</p></li> </ul> <hr> <p>By the way, think about the design - why is <code>Account1</code> a subclass of <code>Customer</code>? A customer <em>is</em> not an account, he <em>has one</em>. </p> <p>So better use delegation here, and think about which part of the information is part of the account, and which is part of the customer. Then one customer could even have multiple accounts (of different types, even).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload