Warning: You are not allowed to use:
1. any static variables
2. any variables which is not inside a function
3. malloc and free
由於實際的code有做其他檢查,因此為了讓各位方便閱讀,請參考簡化版本的function.h與main.cpp(請點連結)
This problem is similar to 11410 - Implement vector, but you have to do more things.
About how the instructions of vector work, please check above link.
This vector has an another operation, which is
You are required to do an employee statistic. Every employees has a name and an unique ID (starts from 0, increment after recruiting an employee).
You will have a class "God" which helps you construct class Employee and read the data members of Employee.
You have to implement
You have to enable C++11 in this problem. (e.g. "g++ -std=c++11 ...")
Hint:
In C++, besides new expression, there is two operations simliar to new expression. One is called "operator new" (allocate memory) and the other is called "placement new" (construct object). You can think "new expression = operator new + placement new".
Here is some examples,
Each input lines may be "recruit [name]", "quit 0 [name]", "quit 1 [id]", "reserve [size]", "capacity" or "size".
"recruit [name]" means push back the employee's [name] to the vector.
"quit 0 [name]" means erase employees from the vector if any employee's name is equal to the [name].
"quit 1 [id]" means erase employees from the vector if any employee's id is equal to the [id].
"reserve [size]" means reserve storage. (Increase the capacity of the container to a value that's greater or equal to new capacity. If new capacity is greater than the current capacity, new storage is allocated, otherwise the method does nothing.)
"capacity" means return the number of elements that can be held in currently allocated storage.
"size" means return the number of elements.
Do the above operations. Print all elements in the vec after doing any operations. The print formate should be "employee_id employee_name\n".