문제

Title probably doesn't make a lot of sense, so I'll start with some code:

class Foo : public std::vector<Foo>
{
};

...

Foo f;

f.push_back( Foo() );

Why is this allowed by the compiler? My brain is melting at this stage, so can anyone explain whether there are any reasons you would want to do this? Unfortunately I've just seen a similar pattern in some production C# code and wondered why anyone would use this pattern.

도움이 되었습니까?

해결책

can anyone explain whether there are any reasons you would want to do this?

Curiously recurring template pattern.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top