Webb7 mars 2008 · You don't need the virtual destructor, unless you're going to use polymorphic behaviour (ie. use your deriving vector through a std::vector*).link: c++ faq[Edited … Webb3 apr. 2024 · Implicit constructor from a vector of 2D points. TPolygon2D ( const std :: initializer_list < TPoint2D >&& vertices ) Constructor from list of vertices data, for example:
c++ - Thou shalt not inherit from std::vector
Webb从 std::vector 继承是不可能的,它可能非常有限(由于没有虚拟析构函数),对其他人来说非常混乱,并且通过组合进行扩展比继承更好/更容易/更易于维护。 Webb29 maj 2024 · Thou shalt not inherit from std::vector. Ok, this is really difficult to confess, but I do have a strong temptation at the moment to inherit from std::vector. I need … flex tool deals
c++ - Avoid template mess when importing base class …
Webb17 juli 2024 · 没有更多信息,这个继承有点可疑. 我可以有充分的理由从 std:: string 继承,但不能从 std::vector 继承. 我需要继承他的对象和列表的功能以及添加. 一些我自己的: class CMyPersonalObject: public CMyObject. {. //更多东西. } class CMyPersonalObjectList: public CMyObjectList. Webb28 sep. 2006 · std::vector does not have a virtual destructor. But it would only need one, if you delete a CorresVector through a pointer to a base class. As for the question whether it is the "right" approach, use google and you will find a lot of different opinions (see e.g. http://www.thescripts.com/forum/thread63869.html). Cheers, Frank Sep 26 '06 # 3 toton Webb26 jan. 2024 · Inheriting from std::vector. One thing I see now I could improve on is that I duplicated the push/pop mechanism of a std::vector. I probably could have used inheritance to implement that, but I don't quite understand how to do that yet. It's probably better not to inherit from std::vector. This might expose all kinds of undesired … chelsea worstall fargo nd