이 코드가 있습니다.다른 클래스 안에 객체를 만드는 방법은 무엇입니까?
#include "Stack.h"
template <class dataType>
class Queue2{
public:
Queue2(int size);
bool push(int data);
bool pop(int &data);
bool isEmpty();
bool isFull();
bool top(int &data);
~Queue2();
};
template <class dataType>
Queue2<dataType>::Queue2(int size = 10) : Stack <dataType> obj1(size), Stack <dataType> obj2(size) {//here i am facing an error. how can i fix it
}
는이 같은 생성자와 templete입니다 클래스 스택 있습니다.
Stack(int size=10);
는 지금은 Queue2 클래스 스택 클래스의 두 개체를 만들려고합니다. 당신이 당신의 Queue2
클래스 두 개인 Stack
멤버를주는 경우에
무엇 두 개체를 의미합니까? 두 개의 멤버 변수? – songyuanyao
Push and pop은 Queue2에 내부 목록이 있음을 나타냅니다. obj1과 obj2를 추가 하시겠습니까? – RvdK
두 개의 스택 객체를 사용하여 Queue를 구현해야합니다. 그 이유는 내가 두 개의 객체를 필요로하는 데이터 membrs .. –