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(1939);
ball b2;
cout << "b1: " << b1.get_m() << endl;
cout << "b2: " << b2.get_m() << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment