PC Review


Reply
Thread Tools Rate Thread

covariant return type

 
 
=?Utf-8?B?UGV0ZXI=?=
Guest
Posts: n/a
 
      10th Feb 2005
Hi,
I am new to .Net, ADO.Net and i have to programm an independent dataprovider
(no sql, no oledb, no odbc) and in addition it has to be in visual c++
untill now i have two classes.
Class Conn derived from IDbConnection and class comm derived from idbcommand.

so my problem is the method 'Comm* CreateCommand' in class Conn, i allways
get the error message error C2392: ..... : Covariant-Returntype
WTF is that?????


__gc class Comm;
__gc class Conn : public IDbConnection
{
......
Comm* CreateCommand(){Comm* cmd = new Comm();
cmd->set_Connection(this);
return cmd;};
IDbCommand* IDbConnection::CreateCommand(){return this::CreateCommand();};
......
}


__gc class Comm : public IDbCommand
{
.......
}
 
Reply With Quote
 
 
 
 
Lionel LASKE
Guest
Posts: n/a
 
      10th Feb 2005

My guess is that compiler generate the same signature for "Comm
*CreateCommand" method and "IDbConnection *CreateCommand". Probably because
Comm inherit from IDbConnection.
I don't understand why you need to have two public methods. May be you can
just rename "Comm *CreateCommand" method to "_CreateCommand".

Just one advice, I experienced the same project: I had to program a data
provider for a legacy data source. I'd choose to have two layers:
- a C++ managed layer in a DLL to call legacy data source
- a C# assembly to implement the ADO.NET provider interface and call my C++
layer.

I think it's simpler than mixed legacy call and ADO.NET interface.

Lionel.

"Peter" <(E-Mail Removed)> a écrit dans le message de news:
2E83D61E-A5EB-4F74-8A4D-(E-Mail Removed)...
> Hi,
> I am new to .Net, ADO.Net and i have to programm an independent
> dataprovider
> (no sql, no oledb, no odbc) and in addition it has to be in visual c++
> untill now i have two classes.
> Class Conn derived from IDbConnection and class comm derived from
> idbcommand.
>
> so my problem is the method 'Comm* CreateCommand' in class Conn, i allways
> get the error message error C2392: ..... : Covariant-Returntype
> WTF is that?????
>
>
> __gc class Comm;
> __gc class Conn : public IDbConnection
> {
> .....
> Comm* CreateCommand(){Comm* cmd = new Comm();
> cmd->set_Connection(this);
> return cmd;};
> IDbCommand* IDbConnection::CreateCommand(){return this::CreateCommand();};
> .....
> }
>
>
> __gc class Comm : public IDbCommand
> {
> ......
> }



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
override virtual, covariant return type Cor Ligthert Microsoft C# .NET 3 1st Apr 2005 07:07 AM
override virtual, covariant return type James Gockel Microsoft C# .NET 6 1st Apr 2005 01:58 AM
Why are there no covariant return types? Stefan Slapeta Microsoft C# .NET 14 5th Jul 2004 02:34 PM
BUG: covariant return types Rob Grainger Microsoft VC .NET 4 15th Nov 2003 04:20 AM
What can I do about Covariant return types? Stephen Walch Microsoft VC .NET 13 24th Oct 2003 02:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:23 PM.