Original Post
hi folks,
i have a base class shown below:
you will notice a virtual function GetVector(). Although the base class has no member variable TVector, i am declaring this virtual function anyway to be used by derived classes which may have TVector variables as members.
The problem is the base class have no TVector member to return to when defining GetVector() , so this is how i defined this function in my base class:
It works, or at least the compiler does not complain. Also, since the base class won't have any TVector variable i do not see any risk to this (or probably i have not discovered any yet).
However, i believe it is illegal to do this. Therefore i would assume this is a the best solution out there. So my question is how should i best define the GetVector() function?
Thanks in advance.
i have a base class shown below:
class CEntity
{
public:
CEntity();
virtual ~CEntity();
const TVector<float, 3>& CEntity::GetVector();
};
you will notice a virtual function GetVector(). Although the base class has no member variable TVector, i am declaring this virtual function anyway to be used by derived classes which may have TVector variables as members.
The problem is the base class have no TVector member to return to when defining GetVector() , so this is how i defined this function in my base class:
const TVector<float, 3>& CEntity::GetVector( long nType )
{
TVector<float, 3> *T = 0;
return *T;
}
It works, or at least the compiler does not complain. Also, since the base class won't have any TVector variable i do not see any risk to this (or probably i have not discovered any yet).
However, i believe it is illegal to do this. Therefore i would assume this is a the best solution out there. So my question is how should i best define the GetVector() function?
Thanks in advance.