[id(1), helpstring("Retrieve recordset by Vehicle Type")]
HRESULT LookupByVehicleType([in] BSTR TemplateName,
[in] BSTR TemplateVersion,
[in] IVehicleType* VehicleType,
[in] VARIANT_BOOL singleMatch,
[in, defaultvalue(0)] VARIANT_BOOL ApplyPrefs,
// I added this
// [in, optional, defaultvalue(0)] VARIANT_BOOL
ApplyPrefs, // also tried this
// [in, optional ] VARIANT_BOOL ApplyPrefs,
// also tried this
[out, retval] IDispatch** AdoRecordset);
Now my C++ code gives me a compile error (C2660) saying the function does
not take 4 parameters. Am I doing something wrong or does C++ just not
support optional parameters?
Existing VB code still compiles.
Mike
"Sharon Fujita" <sfu...@northropgrumman.com> wrote in message
news:Ov6uskK5BHA.1892@tkmsftngp05...
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
"Sharon Fujita" <sfu...@northropgrumman.com> wrote in message
news:Ov6uskK5BHA.1892@tkmsftngp05...
VB works fine with non-VARIANT optional parameters, and the added
type safety is nice in cases where it's not important to know whether
or not a parameter has been specified.
C++ supports optional parameters, but it won't work for a raw procedure
and AFAIK but the C++ wrappers generated from your IDL aren't set up
that way.
For the non-raw procedure, you'd have a declaration something like
this (modified for brevity):
IDispatch** LookupByVehicleType(BSTR, BSTR, IVehicleType*,
VARIANT_BOOL, VARIANT_BOOL ApplyPrefs=0);
The [optional] attribute is valid only if the parameter is of type
VARIANT or VARIANT *.
Also, from the ODL reference:
All subsequent parameters of the function must also be optional.
Dirk
"Craig Powers" <eni...@hal-pc.org> wrote in message
news:3CBB3E71...@hal-pc.org...
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
"dirk" <dha...@hotmail.com> wrote in message
news:u8RCKDO5BHA.2072@tkmsftngp02...
Yes. VB doesn't seem to mind, though.
I started doing this before I realized I could specify defaultvalue
without specifying optional.
> Also, from the ODL reference:
>
> All subsequent parameters of the function must also be optional.
Yes, that's correct. I'm assuming you had a specific application to
either the thread or my message when you wrote this -- could you
please elaborate?