Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Template based override

$
0
0
I am creating Vector class. I want to do it n-dimensional and I have to do it with STL array, not with STL vector
here is my code:
template<typename T,int Dimension>
class Vector{
public:
    Vector(T dim[Dimension])
    {
    int i;
    for(i=0;i<Dimension;i++)
    val[i]=dim[Dimension];
    };
private:
    array<T,Dimension> val;
};



Fine I want to do values x y z and w which will be synonyms for val[0,1,2,3] but i want them to be created only only if Dimension is bigger than 1 2 3 4. I want to override []

Something like T & operator []{return ...}

I haven't found anything.
Is this possible and how?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>