Thread: databse iterator probs

  1. #1
    Registered User mouse163's Avatar
    Join Date
    Dec 2002
    Posts
    49

    databse iterator probs

    I am using the #include<list>
    header with the following declaration of a databaseclass
    for my employees, which will be read by an iterator class.

    The abstract base class has 2 pure virtual functions both of which are overloaded in derived classes...
    then i declare my list and databse but i am getting errors that i cannot seem to break

    Code:
    employee1.cpp
    c:\program files\microsoft visual studio\vc98\include\list(29) : error C2259: 'employee' : cannot instantiate abstract class due to following members:
            C:\Program Files\Microsoft Visual Studio\MyProjects_M\Mcd_Project\employee1.cpp(43) : see declaration of 'employee'
            C:\Program Files\Microsoft Visual Studio\MyProjects_M\Mcd_Project\employee1.cpp(214) : see reference to class template instantiation 'std::list<class employee,class std::allocator<class employee> >' being compiled
    c:\program files\microsoft visual studio\vc98\include\list(29) : warning C4259: 'void __thiscall employee::print(void)' : pure virtual function was not defined
            C:\Program Files\Microsoft Visual Studio\MyProjects_M\Mcd_Project\employee1.cpp(51) : see declaration of 'print'
            C:\Program Files\Microsoft Visual Studio\MyProjects_M\Mcd_Project\employee1.cpp(214) : see reference to class template instantiation 'std::list<class employee,class std::allocator<class employee> >' being compiled
    c:\program files\microsoft visual studio\vc98\include\list(29) : warning C4259: 'double __thiscall employee::pay(void)' : pure virtual function was not defined
            C:\Program Files\Microsoft Visual Studio\MyProjects_M\Mcd_Project\employee1.cpp(52) : see declaration of 'pay'
            C:\Program Files\Microsoft Visual Studio\MyProjects_M\Mcd_Project\employ
    there are 4 errors 6 warnings...and some of them point to the STL list file.
    anyhow here is the syntax that is my problem..can anyone help me?
    Code:
    typedef list< employee > EMPLOYEE_LIST;
    typedef EMPLOYEE_LIST::iterator LISTiterator;
     
    class Employee_Database 
    {
    public:
    
    Employee_Database( const char* filename); 
    ~Employee_Database();
    EMPLOYEE_LIST dataList;
    char databaseFilename[256];
    char dataInputFilename[256];
    
     void showEmployeeMenu();
     void getMenuSelection();
     void Run( char* filename ); 
    private:
     void Hire();
     void Fire();
     void Retire();
    };
     
    //database constructor
    Employee_Database::Employee_Database( char* filename)
    {
    
    strcpy( databaseFilename, filename);
    strcpy( dataInputFilename, "" );
    dataList.clear();
     
     
    }

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    311
    If employee is an abstract base class, that is it has a pure virtual function, then you cannot have a list of employee's. You can have a list of pointers to employee's that point to decendants of employee that have no pure virtual functions.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. helppp in bank databse
    By neha007 in forum C++ Programming
    Replies: 1
    Last Post: 06-02-2007, 09:43 AM
  2. databse connection in C
    By naigin in forum C Programming
    Replies: 3
    Last Post: 02-14-2002, 06:33 AM