以下の内容はhttps://so-wh.at/entry/20080521/p5より取得しました。


親クラスのコンストラクタを呼び出す

これで合ってるのかなー?

#include <iostream>
using namespace std;

class Foo {
private:
  int i;

public:
  Foo(int i) : i(i) {}
  void foo() {
    cout << i << endl;
  }
};

class Bar : public Foo {
public:
  Bar(int i) : Foo(i) {}
  void bar() {
    foo();
  }
};

int main() {
  Bar bar(100);
  bar.foo();
  bar.bar();
  return 0;
}


100
100




以上の内容はhttps://so-wh.at/entry/20080521/p5より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14