Costructor of array of pointers to Abstract objects

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Gannon56789
    New Member
    • Nov 2008
    • 7

    Costructor of array of pointers to Abstract objects

    I have a class from which i must use a constructor that initializes an array of pointers to objects that are Abstract. I keep getting an error when i try to compile this because i guess it is creating Employee objects which i can't do because there is a pure virtual inside employee. What is the proper way to do the constructor so it allocates memory for all the elements of my array?

    Code:
    Employee* Earray[10]; // Declared as private member in payroll
    Payroll::Payroll()
    {
        Earray = new Employee[10];   // Employee is abstract so an error
    }
    
    Payroll::~Payroll()
    {
    
    
         delete [] Earray;
    
    }
Working...