CServerSocket* sock = new CServerSocket();
m_lSock.AddTail(sock); //right, same type
CAsyncSocket* test = new CAsyncSocket();
m_lSock.AddTail(test); //wrong, not same type
对于后面一个,在编译时有提示:
error C2664: 'struct __POSITION *__thiscall CTypedPtrList<class CPtrList,class CServerSocket *>::AddTail(class CServerSocket *)' : cannot convert parameter 1 from 'class CAsyncSocket *' to 'class CServerSocket *'