小编Yus*_*ori的帖子

在C++中使用const成员变量有什么优点

我写代码像

template <typename XAxis, typename YAxis>
class Interpolation {
public:
    using x_value_type = typename XAxis::value_type;
    using y_value_type = typename YAxis::value_type;

    Interpolation(const XAxis& x_axis, const YAxis& y_axis)
        : _x_axis(x_axis), _y_axis(_y_axis)
    {}

public:
    y_value_type interpolate(const x_value_type& x) const;

private:
    const XAxis _x_axis;
    const XAxis _y_axis;
};
Run Code Online (Sandbox Code Playgroud)

当我想要成员变量是不可变的时。

我感到有点焦虑,为什么我认为我可能因某种原因知道上面的代码是非法的或坏的代码。
您认为常量成员变量有什么好处或没有什么好处?
请告诉我你的理由。

c++ header-files

6
推荐指数
1
解决办法
7162
查看次数

谁应迅速将DisposeBag保留在MVVM(+ controller)中

我尝试使用RxSwift + MVVM架构开发iOS应用。
我有个问题。谁应该拥有DisposeBag实例?
现在,我在代码中实现了以下内容。

  • 视图模型具有“变量”的实例。
  • 控制器保留DisposeBag。
  • View订阅可观察视图模型并附加控制器的处置包。

是好的设计吗?
我想要代码标准,请给我您的意见。

mvvm ios swift rx-swift

1
推荐指数
1
解决办法
352
查看次数

标签 统计

c++ ×1

header-files ×1

ios ×1

mvvm ×1

rx-swift ×1

swift ×1