Re: Any problems expected in Multiple inheritance with template class ?
This is a multi-part message in MIME format.
------=_NextPart_000_001D_01C8E35F.1C72E830
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
It does compile successfully and I do not have any nontemplate class =
with the name CCommand.
Case1 : I tried putting in
hr =CCommand<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 = dynamic_cast<CCommand*>(this);
hr = 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 =CCommand::Open(*m_pSession, wstrCmd.c_str(), =
pPropSet);//CRASHES
This should not even compile. It should be CCommand<TAccessor,
TRowset>::Open(...). Do you by any chance have a non-template class
named CCommand somewhere in your program?
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to =
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
------=_NextPart_000_001D_01C8E35F.1C72E830
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=Content-Type content="text/html; =
charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16674" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=Arial size=2>It does compile successfully and I do =
not have any
nontemplate class with the name CCommand.</FONT></DIV>
<DIV><FONT face=Arial size=2><STRONG>Case1 </STRONG>: I tried =
putting
in</FONT></DIV>
<DIV><FONT face=Arial size=2>hr =CCommand<TAccessor, >
TRowset>::Open(*m_pSession, wstrCmd.c_str(), pPropSet);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>then hr return S_FALSE, the open =
function fails in
this case.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><STRONG>Case 2 : </STRONG>It however =
works
absolutely fine when I make the following change before the =
call:</FONT></DIV>
<DIV>
<P><FONT face=Arial size=2>CCommand* pcmd =
dynamic_cast<CCommand*>(this);</FONT></P>
<P><FONT face=Arial size=2>hr = pcmd->Open(*m_pSession, =
wstrCmd.c_str(),
pPropSet);</FONT></P>
<P><FONT face=Arial size=2>I fail to understand what additional =
thing does the
dynamic cast do?</FONT></P>
<P><FONT face=Arial size=2>Why is it not working in Case1 and =
working fine in
case 2?</FONT></P>
<P><FONT face=Arial size=2>Any idea?</FONT></P>
<P><FONT face=Arial size=2>Thanks and Regards</FONT></P>
<P><FONT face=Arial size=2>Ganga</FONT></P></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>"Igor Tandetnik" <</FONT><A
href="mailto:itandetnik@mvps.org"><FONT face=Arial
size=2>itandetnik@mvps.org</FONT></A><FONT face=Arial size=2>> =
wrote in
message </FONT><A =
href="news:%234ynW6r4IHA.1892@TK2MSFTNGP06.phx.gbl"><FONT
face=Arial =
size=2>news:%234ynW6r4IHA.1892@TK2MSFTNGP06.phx.gbl</FONT></A><FONT
face=Arial size=2>...</FONT></DIV><FONT face=Arial size=2>> =
"Ganga Sridhar"
<</FONT><A href="mailto:gangasridhar@abosoftware.com"><FONT =
face=Arial
size=2>gangasridhar@abosoftware.com</FONT></A><FONT face=Arial =
size=2>> wrote
in message<BR>> </FONT><A
href="news:ejFxqvr4IHA.2072@TK2MSFTNGP04.phx.gbl"><FONT face=Arial
size=2>news:ejFxqvr4IHA.2072@TK2MSFTNGP04.phx.gbl</FONT></A><BR><FONT =
face=Arial
size=2>>> I have my derived class<BR>>> CABIOleDbSet : =
public
CCommand<TAccessor, TRowset>, public =
CABISet<BR>>><BR>>>
{<BR>>> ...<BR>>> }<BR>>><BR>>> hr
=CCommand::Open(*m_pSession, wstrCmd.c_str(), =
pPropSet);//CRASHES<BR>>
<BR>> This should not even compile. It should be =
CCommand<TAccessor,
<BR>> TRowset>::Open(...). Do you by any chance have a =
non-template class
<BR>> named CCommand somewhere in your program?<BR>> -- <BR>> =
With best
wishes,<BR>> Igor 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 where they are going to <BR>> =
land, and it
could be dangerous sitting under them as they fly <BR>> overhead. -- =
RFC 1925
<BR>> <BR>></FONT></BODY></HTML>
------=_NextPart_000_001D_01C8E35F.1C72E830--