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(int x) {
m = x;
cout << "コンストラクタ呼出し..." << endl;
}
~ball() { cout << "デストラクタ呼出し..." << endl; }
int get_m() { return m; }
};
void ex_function(ball &b)
{
cout << "Accepted... " << b.get_m() << endl;
}
int main()
{
ball b(9384);
ex_function(b);
return 0;
//今度はデストラクタの呼出しが1度
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment