유형에서 파생되지 typename을 시도해보십시오
template <class T>
class CSafeSet
{
public:
CSafeSet();
~CSafeSet();
typename std::set<T>::iterator Begin();
private:
std::set<T> _Set;
};
당신은 유형 이름이 필요합니다 거기에 템플릿 T에 의존하기 때문에. 코드 위의 링크에 자세한 정보가 있습니다. 보조 노트에
template <class T>
class CSafeSet
{
public:
typedef T value_type;
typedef std::set<value_type> container_type;
typedef typename container_type::iterator iterator_type;
typedef typename container_type::const_iterator const_iterator_type;
CSafeSet();
~CSafeSet();
iterator_type Begin();
private:
container_type _Set;
};
당신이 CSafeSet 사용자 정의 비교자를 사용하여 의미하는 set could 같은 일을 할 수 있도록 할 필요가 완료하려는 경우 : 당신은 타입 정의의를 사용하는 경우 부지의이 물건은 쉽게 만들어 및 할당 : 당신이 클래스 래퍼를 만들려고하는 경우에
template <class T, class Compare = std::less<T>, class Allocator = std::allocator<T> >
class CSafeSet
{
public:
typedef T value_type;
typedef Compare compare_type;
typedef Allocator allocator_type;
typedef std::set<value_type, compare_type, allocator_type> container_type;
typedef typename container_type::iterator iterator_type;
typedef typename container_type::const_iterator const_iterator_type;
// ...
}
그리고 조언의 마지막 비트, 클래스가 어디에서 왔는지와 같은 이름 지정 규칙을 따라야하려고합니다. 즉, Begin()
은 begin()
이어야합니다. (개인적으로 클래스 이름 앞에 C가 이상하다고 생각하지만 그 사람은 당신에게 달려 있습니다.)
참고 사항 : 식별자에서 밑줄을 사용하는 방법에 대해 읽으십시오. http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-ac-identifier/228797#228797 –
짧은 버전 : "식별자 이름을 밑줄로 시작하지 마십시오. " – jalf
긴 버전 : 대문자가 뒤에 오는 밑줄은 컴파일러 용으로 예약되어 있습니다. 더블 언더 스코어 다음에 컴파일러를 위해 예약 된 것도 있습니다. – GManNickG