Forward declaration in Cocos?

Forward declaration in Cocos?

Hi !, i have created a simple struct that manages some functions for all scenes, some parameters are owned by cocos, so i need to forward declare those types.

#ifndef __HELPER_H__
#define __HELPER_H__

#pragma once

struct Color3B;
class Label;

struct helper {

	const float C_LOAD_SCENE_FADE_TIME = 0.5f;

	template <typename T>
	void load_scene(T scn, Color3B col);	
	void write_text_on_label(Label*& et, const char* txt, Color3B col);
	void play_SFX(const char* sfx_file);
	void play_BGM(const char* bgm_file, bool loop = false);


#endif //__HELPER_H__

Then i get the error some incompatible declaration errors, suspect i have not forward declared correctly…

I don’t think you need to forward declare.

Thanks my friend, i know what they are… just needed to use it because i had created a single struct that holds some cocos2d types on header, this is just the same way i use on other frameworks like Qt too…

But i found another way to acchieve what i need.

You can only forward declare class or structure with reference and pointer.

void load_scene(T scn, const Color3B& col);

Unless Label is your own custom class (i.e not CCLabel or Label provided by Cocos) there isn’t a need to forward declare Label here. If Label is a custom class, I’d change the name to avoid confusion.