2016-07-11 1 views
2

나는 중첩 클래스의 다음과 같은 경우가 있습니다어떻게 든 정규화 된 반환 형식 이름을 쓸 수 있습니까?

class PS_OcTree { 
public: 
    // stuff ... 

private: 
    struct subdiv_criteria : public octree_type::subdiv_criteria { 
    PS_OcTree* tree; 
    subdiv_criteria(PS_OcTree* _tree) : tree(_tree) { } 
    virtual Element elementInfo(unsigned int const& elem, node const* n) override; 
    }; 
}; 

.cpp 파일에이 방법을 구현하는 방법을, 나는

PS_OcTree::subdiv_criteria::Element 
PS_OcTree::subdiv_criteria::elementInfo(
    unsigned int const& poly_index, node const* n) 
{ 
    // implementation goes here 
} 

나는 방법의 전체 이름을 쓰기로 괜찮아 쓰기 하지만 정말 반환 형식의 전체 이름을 작성해야합니까? 매개 변수 괄호와 함수 본문 내에서 subdiv_criteria 클래스의 이름에 액세스 할 수 있지만 반환 유형에는 작동하지 않습니다.

가급적, 나는

Element PS_OcTree::subdiv_criteria::elementInfo(
    unsigned int const& poly_index, node const* n) 
{ 
    // implementation goes here 
} 

// or 

auto PS_OcTree::subdiv_criteria::elementInfo(
    unsigned int const& poly_index, node const* n) 
{ 
    // implementation goes here 
} 

같은 반환 형식에 PS_OcTree::subdiv_criteria을 반복 저를 필요로하지 않습니다 적어도 뭔가 뭔가를 쓰고 싶습니다. C++ 11에서 사용할 수있는 것이 있습니까? MSVC 2015 및 Clang 5에서도 작동합니다.

+2

당신은'자동차 PS_OcTree :: subdiv_criteria :: elementInfo ( 부호 INT의 CONST 및 poly_index, 노드 CONST의 * n을)를 작성할 수 있습니다. MSVC가 이것을 지원하면 IDK –

답변

7

클래스 범위 조회 후행 반환형 포함 (정의되는 함수의 이름, 즉 PS_OcTree::subdiv_criteria::elementInfo)를 선언자-ID 후 것도 적용된다. > Element` - 따라서, C++ 11에서

auto PS_OcTree::subdiv_criteria::elementInfo(
    unsigned int const& poly_index, node const* n) -> Element 
{ 
} 
+0

Slick! 고마워, 나는 이것을 파악하지 못했다. :) –