I have made a simple template class:
Code:
template <typename T1>
class POSITIONAL
{
public:
POSITIONAL(T1 varOne, T1 varTwo);
POSITIONAL();
~POSITIONAL();
void operator= (POSITIONAL& rhs);
T1 posX;
T1 posY;
};
template <typename T1>
POSITIONAL<T1>::POSITIONAL(T1 varOne, T1 varTwo)
{
posX = varOne;
posY = varTwo;
};
template <typename T1>
POSITIONAL<T1>::POSITIONAL()
{
posX = 0;
posY = 0;
};
template <typename T1>
void POSITIONAL<T1>::operator= (POSITIONAL<T1>& rhs)
{
posX = rhs.posX;
posY = rhs.posY;
}
template <typename T1>
POSITIONAL<T1>::~POSITIONAL()
{
};
Ok, so I have a few questions.
1) Should each class allocate/de-allocate its own memory. If so, when the compiler sets aside memory for a class (containing one such as this, but say this allocates and the 2 variables are pointers), does it set aside further memory or does it know that this class will do it itself?
2) When you use this class within another class, don't you just need to #include it? Code:Blocks is giving me trouble in not recognizing classes within classes. Keeps telling me "error: 'POSITIONAL' is not a type.