템플릿

purewell의 이미지
7344
points

[완료] 템플릿과 일반클래스를 상속한 템플릿 클래스

-2
points

template <typename T>
class TParent
{
// blar blar...
};

class CInterface
{
  virtual const char* what(void) const = 0;
};

template <typename T>
class TChild : public CInterface, public TParent<typename T>
{
  virtual const char* what(void) const
  {
    return &T;
  }
};

purewell의 이미지
7344
points

[완료] 템플릿 클래스 내부 타입을 쓰고 싶습니다. (typename)

2
points

#include <iostream>
using namespace std;

template<typename T>
class CTest
{
public:
    typedef T   type;

    type& getWhat(type& t);
};

template<typename T>
CTest<T>::type&
CTest<T>::getWhat(CTest::type& t)
{
    return t;
}

위 코드에서 아래에 메서드 정의하는 부분에서 에러가 떨어집니다.

내용묶음