0

I have this error coming out from the following 4 files when compiling. Apparently In Leader.h the namespace Utils is not visible.

I can't get how to fix it, why the class Leader doesn't see the namespace Utils even though I included Utils.h? My first thought is that the problem comes from the fact Utils include Leader and that back, but is there a way to fix it if that so?

Error

In file included from Utils.h:4:
Leader.h:12:5: error: ‘Utils’ does not name a type
   12 |     Utils::CardInfo* getCardInfo();
      |     ^~~~~

Utils.h

#ifndef __UTILS_H__
#define __UTILS_H__

#include "Leader.h"
#include <iostream>

namespace Utils{    
    class CardInfo{
        public:
            union Value {
                char name[50];
                int life;
            } value;
            CardInfo();
    };
};
#endif

Utils.cpp

#include "Utils.h"

Utils::CardInfo::CardInfo(){
    Leader leader(20);
    std::cout << "CardInfo constructor" << std::endl;
}

Leader.h

#ifndef LEADER_H
#define LEADER_H
#include "Utils.h"

class Leader
{
private:
    int _life;
public:
    Leader(int life);
    ~Leader();
    Utils::CardInfo* getCardInfo();
};

#endif

Leader.cpp

#include "Leader.h"

Leader::Leader(int life): _life(life) {};

Utils::CardInfo* Leader::getCardInfo() {
    return new Utils::CardInfo();
};

Leader::~Leader() {};

0 Answers0