storage - C++ - basic container question -


How should the following cases be controlled:

I have some geometrical storage, Which is a template from the top type.

  template & lt; Typename T & gt; Structure geometry {std :: vector & lt; T & gt; & Amp; Griters () {...} const void * rawVertices () const {...}}  

This works fine, as long as I do not store different types of geometries (For example,

Is it possible?

>

Or how can I apply geometry storage (where I can store and retrieve different types of geometry using a container) or else Like T type to public Mittith

Any advice?

Thanks.

Since a container is connected to one type of data, you can create a square geometry , all of which are in the geometry & lt; T & gt; and then Geometry << code> Pointer

  struct geometryBase {// non-templates in your container Methods can go here. Do not forget to forget Class Districts And virtual}; Template & lt; Typename T & gt; Straight geometry: public geometry {// template methods go here}; Edit: At some point, you have to decide what type of top container you want to achieve (My Attitude)  or  What do you want to do? With victory (vision of Matthew Mathew) and then you must dynamic_cast ;> to gain access to derived class methods.  

Another suggestion:
Your comments are different according to your description, it is actually better to treat them in different forms. For example, you can assign each geometry & lt; & Gt; Create a separate container for the template example.

Category SomeStorageClass {/ * ... * / private: std :: vector & lt; Geometry & lt; Vertex1 & gt; & Gt; M_vertex1Geometries; Std :: vector & lt; Geometry & lt; Vertex2 & gt; & Gt; M_vertex2Geometries; };

If you have tasks that work on a type of geometry (using Vertex1 :: GetPos () , for example) or other ( Vertex 2 :: GETUV () ) These functions are likely to apply quite differently and are thus capable of doing different tasks, which are expected for different types of parameters .


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -