부모 클래스가 템플릿 클래스일 경우 자식 클래스에서 부모 클래스로의 액세스 방법
<T>: : 부모클래스 멤버함수 or 멤버변수'예제 코드
template<typename T>
class Deque : public Queue<T>
{
typedef Queue<T> Base;
...
void PushFront(const T& item)
{
if (Base::IsFull())
Base::Resize();
if(Base::front_ == 0)
{
Base::front_ = Base::capacity_;
}
Base::front_ = (Base::front_ - 1) % Base::capacity_;
Base::queue_[(Base::front_ + 1) % Base::capacity_] = item;
}
...
}
this-> 부모멤버'예제 코드
template<typename T>
class Deque : public Queue<T>
{
...
void PushFront(const T& item)
{
if (this->IsFull())
this->Resize();
if(this->front_ == 0)
{
this->front_ = this->capacity_;
}
this->front_ = (this->front_ - 1) % this->capacity_;
this->queue_[(this->front_ + 1) % this->capacity_] = item;
}
...
}