Re: Any problems expected in Multiple inheritance with template class ?
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 =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_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=Content-Type content="text/html; =
charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16674" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hello</FONT></DIV>
<DIV><FONT face=Arial size=2>Thanks CCommand<TAccessor, > =
TRowset>::
resolves all my problems now.</FONT></DIV>
<DIV><FONT face=Arial size=2>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>But its surprising how =
it compiled
successfully when I do not even have any nontemplate class with the =
name
CCommand.</FONT></DIV></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Thanks and Regards</FONT></DIV>
<DIV><FONT face=Arial size=2>Ganga</FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ganga Sridhar" <<A
=
href="mailto:gangasridhar@abosoftware.com">gangasridhar@abosoftware.com=
</A>>
wrote in message <A
=
href="news:%233pjEEz4IHA.3804@TK2MSFTNGP03.phx.gbl">news:%233pjEEz4IHA.=
3804@TK2MSFTNGP03.phx.gbl</A>...</DIV>
<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>
</BLOCKQUOTE></BODY></HTML>
------=_NextPart_000_004B_01C8E370.2DD2A140--