第1题【说明】
已知类LinkedList表示列表类,该类具有四个方法:addElement()、lastElement()、number-OfElement()以及removeLastElement()。四个方法的含义分别为:
void addElement(Object):在列表尾部添加一个对象;
Object lastElement():返回列表尾部对象;
int numberOfElement():返回列表中对象个数;
void removeLastElement():删除列表尾部的对象。
现需要借助LinkedList来实现一个Stack栈类,C++代码1和C++代码2分别采用继承和组合的方式实现。