TQueue<enum> initialisation issue and issue using enum

Hi,
I would like to make a TQueue of enum and there is a problem : I don’t know how to initialize it.
I also want to use an enum as parameter in a function and it doesn’t find the enum declaration.

In my .h I have :

...
class ALabyrinth : public AActor
{
...
protected:
	void creerChambre(ETypeChambre type);
	TQueue<ETypeChambre> typeFromHash;
public:
	void creerLabyrinth(int hash);
}

UENUM(BlueprintType)
enum ETypeChambre:int
{
	CLOSED = 0,
	N    = 0x01,
	S    = 0x02,
	E    = 0x04,
	W    = 0x08
}

and in my .cpp :

void ALabyrinth::creerLabyrinth(int hash)
{
	typeFromHash = new TQueue();
        typeFromHash.Enqueue(static_cast<ETypeChambre>(hash &= 0x0f));
}
void ALabyrinth::creerChambre(ETypeChambre type)
{
}

the building led me to two errors:
it seems it don’t know my Enum “Syntax error identifier ETypeChambre” and “identifier not declared ‘ETypeChambre’” for my function “creerLabyrinth”

And it doesn’t have the constructor for my queue, and it tells me it’s not initialized for my function creerLabyrinth.

Can you help me? I searched on google for how to initialize a Equeue and i dont find anything with any example.

At the quick glance i see a two doubtful moments:

  1. In your snippet your define ETypeChambre after you using it to define a variable in ALabyrinth, when you should define it before instead (or use forward declaration).

  2. Container defined like TQueue<ETypeChambre> typeFromHash; is not a pointer and is already created for you by compiler, you don’t need to new T() it.

Also, as I can see, there is only empty constructor available for TQueue, so there is no fancy tricks to initialize it: you have to create empty queue and Enqueue() elements you need.

Also, depending on your needs (sometimes you need things like random access in your queue), you may wish to use TArray instead. On low elements number performance impact can be negligible.

1 Like

So sorry and thank you!

I feel a bit dumb, i already tried to use the queue without initialization it but it doesn’t work, so i focused on it but it was the order of definition…
Long time not dealing with C or C++ and the rigor of this kind of language…

And I need to access the list in FIFO or FILO, I don’t want to get it the wrong way.

Thanks again!