C2674 Error W/ Derived
Hieu Nguyen -- Hieu_Nguyen@cpqm.mail.saic.com
Tuesday, September 03, 1996
CMyString* CMyString::operator=( LPSTR str )
{
CString::operator=( str );
return this;
}
if this code is valid we don't have to rewrite code for CString::operator=()
as mentioned in article below:
>-----From: "(Bobby)Babak Lashkari"
>
>overloaded operator = is not inherited and neither is the copy constructor.
>you should implement a operator = for your new class and copy the code from
^^^^^^^^^^^^^^^^^^^^^^
>CString::operator =.
^^^^^^^^^^^^^^^^^^^^^
>
Dulepov Dmitry -- dima@ssm6000.samsung.ru
Thursday, September 05, 1996
[Mailer: "Groupware E-Mail". Version 1.0]
According to Bjarne Stroustrup your code is now correct (in part of=
calling
base class operator=3D). But look to the definitions in AFX.H:
const CString& operator=3D(const CString& stringSrc);
const CString& operator=3D(TCHAR ch);
#ifdef _UNICODE
const CString& operator=3D(char ch);
#endif
const CString& operator=3D(LPCSTR lpsz);
const CString& operator=3D(LPCWSTR lpsz);
const CString& operator=3D(const unsigned char* psz);
Do you really need to return "CMyString*" instead of "const CString=
&" ? This is
not convenient in most cases. If you want to follow MFC definition =
style,
you may write something like this:
const CMyString& CMyString::operator=3D(LPSTR str)
{
CString::operator=3D(str);
return *this;
}
Good luck! :-)
Dmitry A. Dulepov
Groupware Group
Samsung Electronics Co., Ltd., Russian Research Center
Tel.: +7(095)213-9207
Fax.: +7(095)213-9196
E-Mail (Internet): dima@src.samsung.ru
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
-----------------------------
> [From: Hieu Nguyen
> [Address: Hieu_Nguyen@cpqm.mail.saic.com
> [To: Dmitry A. Dulepov
> [Date: Wed Sep 04 17:20:06 1996
>CMyString* CMyString::operator=3D( LPSTR str )
>{
> CString::operator=3D( str );
> return this;
>}
>
>if this code is valid we don't have to rewrite code for CString::o=
perator=3D()
>as mentioned in article below:
>
>>-----From: "(Bobby)Babak Lashkari"
>>
>>overloaded operator =3D is not inherited and neither is the copy =
constructor.
>>you should implement a operator =3D for your new class and copy t=
he code from
> =
=
> ^^^^^^^^^^^^^^^^^^^^^^
>>CString::operator =3D.
> ^^^^^^^^^^^^^^^^^^^^^
>>
>
>=
| Вернуться в корень Архива
|