I am getting compiler "error C2248: 'CTest<T>::m_element' : cannot access private member declared in class 'CTest<T>' ." I don't know why the private member variable can't be accessed in this case? Please explain the problem.
template <typename T>
class CTest
{
.....
void Add(T& tempElement);
Thanks, but I want to understand the sample using different types.
@ne555
Thanks. It works well by adding friend function and very much convincing too.
1 2 3 4 5 6 7 8 9 10
template <typename T>
template <typename T2>
CTest<T>& CTest<T>::operator =(CTest<T2>& rhs)
{
// here private member variables can be accessible for the calling object & not an issue.
// But the passed object is a different type, CTest <T2>.
// Thats why we couldn't able to access rhs's private member variable, right ?
}