Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#include <iostream>
using namespace std;
//仮引数を持たないコンストラクタの例
class ball {
int m;
public:
ball() { m = 0; }
ball(int x){ m = x; }
int get_m() { return m; }
};
int main()
{
//初期化する配列としない配列の使い分け
ball b1[5];
ball b2[5] = {84848,83828,1019,233,45321};
int i;
for (i = 0; i < 5; i++) cout << b1[i].get_m() << endl;
for (i = 0; i < 5; i++) cout << b2[i].get_m() << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment