thank bạn. mình cũng nghĩ vậy
mình học lập trình cocos2dx thì có đoạn code bên .h như sau
class HelloWorld : public cocos2d::Layer
{
public:
static cocos2d::Scene* createScene();
virtual bool init();
// a selector callback
void menuCloseCallback(cocos2d::Ref* pSender);
// implement the "static create()" method manually
CREATE_FUNC(HelloWorld);
};
ở đoạn này static tạo 1 biến createScene() hay là phương thức createScene() bạn nhỉ mà bên .cpp lại định nghĩa.
nhưng đoạn code bên .cpp
thì gần như vẫn là
Scene* HelloWorld::createScene()
{
// ‘scene’ is an autorelease object
auto scene = Scene::create();
// 'layer' is an autorelease object
auto layer = HelloWorld::create();
// add layer as a child to scene
scene->addChild(layer);
// return the scene
return scene;
}
bạn có thể giải thích giúp mình cách thức con trỏ ở trong static đối với createScene() không bạn