2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[openFrameworks] スマートポインタを使ってスマートにparticleを飛ばす

Last updated at Posted at 2018-07-18

先輩から教えてもらった方法をメモ。

Particleクラスみたいなものをつくって、それをvectorにぶち込んで大量に飛ばしたくなる時ってままありますよね。

##良くある実装例
###ofApp.h

vector<Particle> mParticle;

###ofApp.cpp

Particle tmpP;
mParticle.push_back(tmpP);

##スマートポインタを使った実装例
###ofApp.h

vector<ofPtr<Particle> > mParticle;

###ofApp.cpp

ofPtr<Particle> tmpP = ofPtr<Particle>(new Particle);
mParticle.push_back(tmpP);

スマートです。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?