[winrt]Unable to initialize the base class of projected type

410 Views Asked by At

i'm a newer to cpp/winrt, i use implements_type and base_type to initialize the base class of projected type, but compile error.

namespace Velkhana
{
  [default_interface]
  unsealed runtimeclass Only{
    Only(Object inner);
    ....
  }
}

local class:

class Only2 : public winrt::implements<Only2, Velkhana::Only>
{
    Only2() : implements_type(box_value(true)) {
    }
};
this compile error:  error C2664: 'winrt::implements<Only2,winrt::Velkhana::Only>::implements(const winrt::implements<Only2,winrt::Velkhana::Only> &)': cannot convert argument 1 from 'winrt::Windows::Foundation::IInspectable' to 'const winrt::implements<Only2,winrt::Velkhana::Only> &'

why can't i init base class in this case?

[Image](https://i.stack.imgur.com/oL9GH.png)
https://i.stack.imgur.com/oL9GH.png

I analyzed the source code, but don't find winrt::implements constructor, how local class initializes the grandparent class by implements_type ?
Is there any trick here?
0

There are 0 best solutions below