小编has*_*san的帖子

bash使用zsh等快捷方式扩展cd

是否有可能在bash中扩展类似的东西

cd /u/lo/b<点击标签>

cd /usr/local/bin

bash expand cd path

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

在公共场合使用"使用"继承私有构造函数并不公开

"使用"私有成员变量使其成为公共成员,但构造函数保持私有.例:

class MyClass;

class Base
{
  private:
    Base(float v) : m_v{v} {}
    float m_v;

    friend MyClass;
};

class MyClass: public Base
{
  public:
    using Super = Base;

    using Super::Super; // this is still private
    using Super::m_v; // this is public
};

int main()
{
  MyClass x{3.4f}; // error - calling a private constructor of class 'Base'
  (void)x.m_v; // not an error

  return 0;
}
Run Code Online (Sandbox Code Playgroud)

除了写这样的通用ctor之外还有其他方法吗?

template<typename... Args>
MyClass(Args&&... args) : Super(std::forward<Args>(args)...) {}
Run Code Online (Sandbox Code Playgroud)

c++ inheritance constructor

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

标签 统计

bash ×1

c++ ×1

cd ×1

constructor ×1

expand ×1

inheritance ×1

path ×1