I have two classes:
template <class T>
class TArray
{
public:
TArray& operator =(const TArray &array) { return Copy(array); }
virtual TArray& Copy(const TArray &array) { ... }
}
class TString : public TArray<TCHAR>
{
public:
TString& Copy(const TString &string) { ... }
}
Classes also have needed constructors.
But method Copy
in second class does not override method in first class.
Consider this code:
TString a = _T("aaa");
TString b;
b = a;
In third line program enters assignment operator in TArray
. In it this
and array
are really of type TString
. But when Copy
is called, program enters method TArray::Copy, not TString::Copy as I expected. Why?
I'm using Visual Studio 2015 RC, but I'm moving some code from Visual Studio 6.0 project, and I'm pretty sure it has worked in it. Is something changed?
You're not overriding anything because the methods have different signatures:
vs