We can initialize variables differently in C++ and Cocos. Can anyone explain them and which should we use. Should we use different ones for different reasons. Just general knowledge if you understand them well. So that i can understand them better. Thanks
EXAMPLE ONE - H
#ifndef TESTCLASS_H
#define TESTCLASS_H
#include "cocos2d.h"
class TestClass
{
public:
TestClass(){};
~TestClass(){};
private:
float m_Scale = 0.0f;
cocos2d::Sprite* m_Cursor = cocos2d::Sprite::create("image.png");
};
#endif // TESTCLASS_H
EXAMPLE ONE - CPP
#include "TestClass.h"
`//NOTHING IN CPP`
EXAMPLE TWO - H
#ifndef TESTCLASS_H
#define TESTCLASS_H
#include "cocos2d.h"
class TestClass
{
public:
TestClass();
~TestClass(){};
private:
float m_Scale;
cocos2d::Sprite* m_Cursor;
};
#endif // TESTCLASS_H
EXAMPLE ONE - CPP
#include "TestClass.h"
TestClass::TestClass(){
m_Scale= 0.0f;
m_Cursor = cocos2d::Sprite::create("image.png");
}
EXAMPLE THREE - H
#ifndef TESTCLASS_H
#define TESTCLASS_H
#include "cocos2d.h"
class TestClass
{
public:
TestClass();
~TestClass(){};
private:
float m_Scale;
cocos2d::Sprite* m_Cursor;
};
#endif // TESTCLASS_H
EXAMPLE THREE - CPP
#include "TestClass.h"
TestClass::TestClass():
m_Scale(0.0f),
m_Cursor(cocos2d::Sprite::create("image.png"))//NOT SURE IF THIS ACTUALLY WORKS
{}