locked
Regarding class and object RRS feed

  • Question

  • User-1590429200 posted

    I have two classes ClsEmployee and inhertited class ClsEmployeeDoc.

    1.  

    ClsEmployee Emp;
    Emp = new ClsEmployee();

    Emp = new ClsEmployeeDoc();

    2. 

    ClsEmployee Emp;
    Emp = new ClsEmployee();

    ClsEmployee Emp1;

    Emp1 = new ClsEmployeeDoc();

    what is the difference between the two??

    Thursday, June 13, 2013 2:42 AM

Answers

  • User-1618234021 posted

    In both cases, the reference of the parent is pointing to the object of child calss. The only difference is in 1st case you lose the reference to the parent object.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 13, 2013 4:37 AM

All replies

  • User-1910946339 posted

    In the first one you have one variable.  The ClsEmployee instance that you created is no longer referenced and available for garbage collection.

    In the second one you have two variables.

    Did you have a specific question?

    Thursday, June 13, 2013 4:31 AM
  • User-1618234021 posted

    In both cases, the reference of the parent is pointing to the object of child calss. The only difference is in 1st case you lose the reference to the parent object.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 13, 2013 4:37 AM