Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Plain Text by h ( 13 years ago )
#include <iostream>
template<class T, int i> class Vector
{
protected:
T* m_values;
unsigned m_size;
public:
Vector()
: m_size(i)
{
m_values = new T[m_size];
}
//Dtor
~Vector() { delete m_values; }
T& at(unsigned p_pos)
{
return m_values[p_pos];
}
};
template<class T> class Vector2: public Vector<T,2>
{
public:
typedef Vector<T,2> Base;
Vector2(T x, T y) : Base()
{
m_values[0] = x;
m_values[1] = y;
}
};
int main()
{
Vector2<float> test(1.0f,2.0f);
std::cout<<test.at(0)<<std::endl;
system("Pause");
return 0;
}
Revise this Paste