Overloading of COM-Methods still possible? 
Author Message
 Overloading of COM-Methods still possible?

Hi!
I've encountered this problem: I'd like to have equally-named methods
in my COM automation interface with different parameters. I've read
that COM actually doesn't allow for method overloading, however, when
I implement this interface with Visual J++, I can very well define
overloaded methods that work as desired when calling from JScript for
example. So somehow it must work - at least Visual J++ creates a COM
interface behind the scenes that is capable of method overloading.
So is there a way of doing something similiar in C++ too?

***
Actually I think I don't need method overloading as much as I need
default parameters, since the scenario I use is something like this
(JScript):

Quote:
>> resultset = COMObject.queryDB(sqltext) <<

and an the other hand
Quote:
>> resultset = COMObject.queryDB(sqltext,params) <<

so it would suffice to provide a default parameter for the second
argument (params) in case it is not supplied through the function call
like in the second code example. params would then be something like a
VARIANT, but I already found out that, if I have a COM-method
check(VARIANT v), and I call it with
Quote:
>> check(2)

it's alright, and if I call it with
Quote:
>> check(undefined)

it's still alright (v has then the "value" VT_EMPTY), but calling
Quote:
>> check()

produces an error, though I always thought that undefined is something
like an empty value in JScript.
Having a default parameter in the method implementation doesn't
prevent this error, obviously it shoud somehow be reflected in the
interface definition...

Any ideas?

Thanks in advance

Torsten



Fri, 25 Feb 2005 01:33:04 GMT  
 Overloading of COM-Methods still possible?
look at the 'defaultvalue' midl language attribute...


Quote:
> Hi!
> I've encountered this problem: I'd like to have equally-named methods
> in my COM automation interface with different parameters. I've read
> that COM actually doesn't allow for method overloading, however, when
> I implement this interface with Visual J++, I can very well define
> overloaded methods that work as desired when calling from JScript for
> example. So somehow it must work - at least Visual J++ creates a COM
> interface behind the scenes that is capable of method overloading.
> So is there a way of doing something similiar in C++ too?

> ***
> Actually I think I don't need method overloading as much as I need
> default parameters, since the scenario I use is something like this
> (JScript):
> >> resultset = COMObject.queryDB(sqltext) <<
> and an the other hand
> >> resultset = COMObject.queryDB(sqltext,params) <<
> so it would suffice to provide a default parameter for the second
> argument (params) in case it is not supplied through the function call
> like in the second code example. params would then be something like a
> VARIANT, but I already found out that, if I have a COM-method
> check(VARIANT v), and I call it with
> >> check(2)
> it's alright, and if I call it with
> >> check(undefined)
> it's still alright (v has then the "value" VT_EMPTY), but calling
> >> check()
> produces an error, though I always thought that undefined is something
> like an empty value in JScript.
> Having a default parameter in the method implementation doesn't
> prevent this error, obviously it shoud somehow be reflected in the
> interface definition...

> Any ideas?

> Thanks in advance

> Torsten



Fri, 25 Feb 2005 04:32:13 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. is operator overloading possible in C

2. is CALLBACK function overloading possible ?

3. is it possible to overload operator = ?

4. COM/ATL novice:passing object pointers through methods on a COM interface

5. Return a pointer to a nested COM object from a COM object method

6. Enable COM clients call methods inside COM events

7. COM client crashes calling COM method

8. No overloaded methods in C# and VB.NET?

9. why overloading method On?

10. Overloading Methods exposed through an Interface

11. Method Overloading???

12. How to provide overloaded methods in ATL interface?

 

 
Powered by phpBB® Forum Software