I'm trying to create a database using maps.
The default constructors for the base class and the derived class essentially add details to these maps. (Create an ID number, and take keyboard input for a name, Job Title, contact number, then store these in 3 maps <ID, Name>, <ID, Job Title>, <ID, ContactNo>. The destructor is then called).
Because it destructs after being called, it allows a piece of code like:
1 2 3 4 5 6
|
char Decision1='Y';
while(Decision1=='Y'){
Positions Ne1; // Create new record using default const.
cout << "Would you like to add another record? [Y/N]" << endl;
cin >> Decision1;
};
|
Ne1 can be created multiple times without worrying about loss of data (The details for the object are stored in the maps independant of the class)
The derived class and base class should have separate databases - the derived class constructor stores Positions within the Organization, and the base class constructor stores employee records.
I'm trying to build up so that when an Employee record is added, the Positions database can be searched for the job title entered to see if it exists.
Problem is - when I call the Positions (derived class) default constructor, it calls the Employee (base class) default constructor first.
First - is it standard for a derived class to call the base class constructor first?
Second - if so, is there a workaround, or do I have to plan out my system again?