Re: Any problems expected in Multiple inheritance with template class ? by Ganga
Ganga
Fri Jul 11 05:37:11 CDT 2008
This is a multi-part message in MIME format.
------=_NextPart_000_004B_01C8E370.2DD2A140
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hello
Thanks CCommand<TAccessor, > TRowset>:: resolves all my problems now.
But its surprising how it compiled successfully when I do not even have =
any nontemplate class with the name CCommand.
Thanks and Regards
Ganga
"Ganga Sridhar" <gangasridhar@abosoftware.com> wrote in message =
news:%233pjEEz4IHA.3804@TK2MSFTNGP03.phx.gbl...
It does compile successfully and I do not have any nontemplate class =
with the name CCommand.
Case1 : I tried putting in
hr =3DCCommand<TAccessor, > TRowset>::Open(*m_pSession, =
wstrCmd.c_str(), pPropSet);
then hr return S_FALSE, the open function fails in this case.
Case 2 : It however works absolutely fine when I make the following =
change before the call:
CCommand* pcmd =3D dynamic_cast<CCommand*>(this);
hr =3D pcmd->Open(*m_pSession, wstrCmd.c_str(), pPropSet);
I fail to understand what additional thing does the dynamic cast do?
Why is it not working in Case1 and working fine in case 2?
Any idea?
Thanks and Regards
Ganga
"Igor Tandetnik" <itandetnik@mvps.org> wrote in message =
news:%234ynW6r4IHA.1892@TK2MSFTNGP06.phx.gbl...
> "Ganga Sridhar" <gangasridhar@abosoftware.com> wrote in message
> news:ejFxqvr4IHA.2072@TK2MSFTNGP04.phx.gbl
>> I have my derived class
>> CABIOleDbSet : public CCommand<TAccessor, TRowset>, public CABISet
>>
>> {
>> ...
>> }
>>
>> hr =3DCCommand::Open(*m_pSession, wstrCmd.c_str(), =
pPropSet);//CRASHES
>=20
> This should not even compile. It should be CCommand<TAccessor,=20
> TRowset>::Open(...). Do you by any chance have a non-template class=20
> named CCommand somewhere in your program?
> --=20
> With best wishes,
> Igor Tandetnik
>=20
> With sufficient thrust, pigs fly just fine. However, this is not=20
> necessarily a good idea. It is hard to be sure where they are going =
to=20
> land, and it could be dangerous sitting under them as they fly=20
> overhead. -- RFC 1925=20
>=20
>
------=_NextPart_000_004B_01C8E370.2DD2A140
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.6000.16674" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hello</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Thanks CCommand<TAccessor, > =
TRowset>::=20
resolves all my problems now.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>But its surprising how =
it compiled=20
successfully when I do not even have any nontemplate class with the =
name=20
CCommand.</FONT></DIV></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks and Regards</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Ganga</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ganga Sridhar" <<A=20
=
href=3D"mailto:gangasridhar@abosoftware.com">gangasridhar@abosoftware.com=
</A>>=20
wrote in message <A=20
=
href=3D"news:%233pjEEz4IHA.3804@TK2MSFTNGP03.phx.gbl">news:%233pjEEz4IHA.=
3804@TK2MSFTNGP03.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>It does compile successfully and I do =
not have=20
any nontemplate class with the name CCommand.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>Case1 </STRONG>: I tried =
putting=20
in</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>hr =3DCCommand<TAccessor, >=20
TRowset>::Open(*m_pSession, wstrCmd.c_str(), =
pPropSet);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>then hr return S_FALSE, the open =
function fails=20
in this case.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>Case 2 : </STRONG>It however =
works=20
absolutely fine when I make the following change before the =
call:</FONT></DIV>
<DIV>
<P><FONT face=3DArial size=3D2>CCommand* pcmd =3D=20
dynamic_cast<CCommand*>(this);</FONT></P>
<P><FONT face=3DArial size=3D2>hr =3D pcmd->Open(*m_pSession, =
wstrCmd.c_str(),=20
pPropSet);</FONT></P>
<P><FONT face=3DArial size=3D2>I fail to understand what additional =
thing does the=20
dynamic cast do?</FONT></P>
<P><FONT face=3DArial size=3D2>Why is it not working in Case1 and =
working fine in=20
case 2?</FONT></P>
<P><FONT face=3DArial size=3D2>Any idea?</FONT></P>
<P><FONT face=3DArial size=3D2>Thanks and Regards</FONT></P>
<P><FONT face=3DArial size=3D2>Ganga</FONT></P></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>"Igor Tandetnik" <</FONT><A=20
href=3D"mailto:itandetnik@mvps.org"><FONT face=3DArial=20
size=3D2>itandetnik@mvps.org</FONT></A><FONT face=3DArial =
size=3D2>> wrote in=20
message </FONT><A =
href=3D"news:%234ynW6r4IHA.1892@TK2MSFTNGP06.phx.gbl"><FONT=20
face=3DArial =
size=3D2>news:%234ynW6r4IHA.1892@TK2MSFTNGP06.phx.gbl</FONT></A><FONT=20
face=3DArial size=3D2>...</FONT></DIV><FONT face=3DArial size=3D2>> =
"Ganga Sridhar"=20
<</FONT><A href=3D"mailto:gangasridhar@abosoftware.com"><FONT =
face=3DArial=20
size=3D2>gangasridhar@abosoftware.com</FONT></A><FONT face=3DArial =
size=3D2>>=20
wrote in message<BR>> </FONT><A=20
href=3D"news:ejFxqvr4IHA.2072@TK2MSFTNGP04.phx.gbl"><FONT face=3DArial =
=
size=3D2>news:ejFxqvr4IHA.2072@TK2MSFTNGP04.phx.gbl</FONT></A><BR><FONT=20
face=3DArial size=3D2>>> I have my derived class<BR>>> =
CABIOleDbSet :=20
public CCommand<TAccessor, TRowset>, public=20
CABISet<BR>>><BR>>> {<BR>>> ...<BR>>>=20
}<BR>>><BR>>> hr =3DCCommand::Open(*m_pSession, =
wstrCmd.c_str(),=20
pPropSet);//CRASHES<BR>> <BR>> This should not even compile. It =
should=20
be CCommand<TAccessor, <BR>> TRowset>::Open(...). Do you by =
any=20
chance have a non-template class <BR>> named CCommand somewhere in =
your=20
program?<BR>> -- <BR>> With best =
wishes,<BR>> Igor=20
Tandetnik<BR>> <BR>> With sufficient thrust, pigs fly just fine. =
However, this is not <BR>> necessarily a good idea. It is hard to =
be sure=20
where they are going to <BR>> land, and it could be dangerous =
sitting under=20
them as they fly <BR>> overhead. -- RFC 1925 <BR>> =
<BR>></FONT>=20
</BLOCKQUOTE></BODY></HTML>
------=_NextPart_000_004B_01C8E370.2DD2A140--