By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,501 Members | 1,704 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,501 IT Pros & Developers. It's quick & easy.

Costructor of array of pointers to Abstract objects

P: 7
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?

Expand|Select|Wrap|Line Numbers
  1.  
  2. Employee* Earray[10]; // Declared as private member in payroll
  3. Payroll::Payroll()
  4. {
  5.     Earray = new Employee[10];   // Employee is abstract so an error
  6. }
  7.  
  8. Payroll::~Payroll()
  9. {
  10.  
  11.  
  12.      delete [] Earray;
  13.  
  14. }
  15.  
  16.  
  17.  
  18.  
  19.  
Nov 12 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.