スタックとキューの実装(リンクリストベース)を作成しました。スタックが1つあります(bigStack
)。たとえば、私は分離しますbigStack
(例:stackA
とstackB
)。私pop()
はからのノードbigStack
、私push()
はstackA
。同じように、私push()
はstackB
。変わらないbigStack
。したがって、オブジェクトのクローンを作成しbigStack
ます。C ++でオブジェクトのクローンを作成するにはどうすればよいですか?または、私の問題に対する別の解決策はありますか?
class Stack : public List {
public:
Stack() {}
Stack(const Stack& rhs) {}
Stack& operator=(const Stack& rhs) {};
~Stack() {}
int Top() {
if (head == NULL) {
cout << "Error: The stack is empty." << endl;
return -1;
} else {
return head->nosu;
}
}
void Push(int nosu, string adi, string soyadi, string bolumu) {
InsertNode(0, nosu, adi, soyadi, bolumu);
}
int Pop() {
if (head == NULL) {
cout << "Error: The stack is empty." << endl;
return -1;
} else {
int val = head->nosu;
DeleteNode(val);
return val;
}
}
void DisplayStack(void);
};
それから...
Stack copyStack = veriYapilariDersi;
copyStack.DisplayStack();