0

我是 cpp/winrt 的新手,我使用 implements_type 和 base_type 来初始化投影类型的基类,但编译错误。

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

本地类:

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?
4

0 回答 0