cost 88 ms
Kotlin - 使用来自扩展 class 的 function 对属性的 json 进行编码 - Kotlin - encode json of properties using function from extended class

我尝试使用扩展 class 中的 function 来 Json.encodeToString: 孩子 class 家长 class 使用 这得到“{}”。 我认为它需要父 class 的属性。 编辑: 我需要在 Serializable class 中进行注释,因为我需要将不同的对象放到一个 fu ...

试图将基数 class 指针转换为派生 class object 实现的接口 - Trying to cast base class pointer to a interface that derived class object implements

我在 C++ 中对 inheritance 进行了一些实验,我踩到了一个我不太明白的案例。 当我尝试编译代码时,我得到: 错误:无法将“dynamic_cast”“base”(类型为“class Base*”)键入“class SomeInterface*”(源类型不是多态的) 我认为这不是正确的转 ...

为什么在继承 `bitstring.BitArray` 时,子构造函数的第一个参数被用于父构造函数? - Why is the first argument of child's constructor being used in parent's constructer when inheriting `bitstring.BitArray`?

我希望我的 class 继承BitArray class 但我在构造函数中遇到了问题。 我有几个位置和关键字 arguments 我想在孩子中使用,但由于某种原因,第一个位置参数总是在父母中使用。 有谁知道这是为什么以及如何解决它? 示例代码: Output: ab的 output 应该是空的 ...

在 Swift / UIKit 中,你如何将 UIView 的“基础”class 推广到其他视图类型,因为你不能在各种 UIView 类型中组合太多 - In Swift / UIKit, how do you generalize a "base" class of UIView to other view types, given that you can't compose much in the various UIView types

说我有 然后我有各种自定义视图GreenPlastic: Plastic , YellowPlastic: Plastic等。 我想对堆栈视图做同样的事情。 目前我使用复制粘贴工程: 请注意,您不能编写(除非我完全误解了什么,如果我错了请告诉我)UIView 类、布局子视图等中的任何好东西。 (显 ...

为什么隐藏的 function 正在使用派生的 class 变量? - Why is a hidden function is using derived class variable?

这是一个非常基本的程序,但我认为有必要消除我的疑虑。 下面程序的 output 是disp in base, x = 100 。 在下面的程序中,我只在派生的 class object 中设置x的值,它又从基 class 继承它。在基 class 中, x被初始化为值10 。 我无法理解的是,当我 ...

歧视联盟 Python - Discriminated union in Python

赏金将在 6 天后到期。 此问题的答案有资格获得+400声望赏金。 mnowotka想让更多人关注这个问题: 我希望赏金获得者将提供一个尊重问题中提供的约束的解决方案。 具体来说,“为什么你做的完全不同”的答案将不会被接受,除非他们清楚地展示了一种替代方法,并提供了代码示例和关于优缺点的讨论。 ...

Flutter Class 继承 - Flutter Class inherence

我在使用超级类和子类构造函数时遇到问题。 我在 super class 中声明了一组变量,我在我的子类上调用了 super,但是我无法通过子类访问超类变量。 如下所示,在我的 fromJson 方法中,我无法访问 TennisAttributes 中的 userRating 字段。 ...

在派生的 class 中永久向下转换泛型 - Permanently downcast a generic in a derived class

好的,场景是我有几个共享相似行为的服务,并且都包含在它们之间共享的设置。 这些服务有自己的扩展服务特定设置,我无法在派生服务 class 中访问这些设置。下面基本上是我正在尝试做的事情的示例。public abstract class BaseSettings<T> where T : ...

Typescript - 将子属性“链接”到父属性中的相同属性,因此当更新父属性时,它会更新子属性中的相同属性吗? - Typescript - "Link" a child attribute to the same attribute in the parent, so when the parent attribute is updated, it updates the same in the child?

公司可以有 Pia 协议,但不一定要有。 所以,我有以下 .ts 类来演示这一点。 我只是这样做let submitObject = new Company(); 然后我得到一个公司 object,默认值为 null,我可以根据我的表单中的内容覆盖这些值。 当我在公司中设置“id”时,我希望它也 ...

防止通过派生 class 调用基 class 中的 static 方法? - Preventing a static method in base class from being called through derived class?

我有一个 Base class,以及一个从它继承的 Derived 模板。 这两个都定义了一个 static 方法calculateSize()但具有不同的方法签名。 (两者都被实例化为对象;Base 不仅仅是一个接口。) 如果调用 Derived 类型,则此方法的 Base 类版本会给出错误答 ...

使用仅给定类型 object 的装饰器调用数据类构造函数 - Calling a dataclass constructor with decorator given only a type object

我有一个数据类,它继承了一个抽象的 class,它实现了一些样板,并且还使用@validate_arguments装饰器在创建 object 时立即将字符串转换回数字。 数据类是一系列数字,其中一些是在__post_init__中计算的。 report.py : 然后我有另一个 class,它用R ...

无法将派生的原始指针分配给基 unique_ptr - Cannot assign derived raw pointer to base unique_ptr

我有一些代码看起来像这样: 整个代码太大(而且是机密),无法在此处发布,但这段代码总结得很好。 本质上,我有一个基类 class 和一些派生类。 我还有一个管理器,它使用指向该基数 class 的(智能)指针。 以及一个返回适当 Derived object 的工厂方法(尽管签名返回一个Base* ...

我在 IEquatable(Of T) 上遇到 CA1067 违规,无法解决 - I am having a CA1067 violation on IEquatable(Of T) and can't solve it

我已经尝试了几个小时并进行了大量重新编码,但可以摆脱 CA1067 违规。 使用: Visual Studio 2022,.Net v6.0.13,VB.NET 对于解决问题的任何帮助以及对我做错事的见解,我将不胜感激。 所以案例如下: 我有一个模板 class SimNode SimNode(O ...


 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM