I made some namespace Game and class named Button. And I Defined the functions in cpp file. Can I use "using namespace Game;" in this cpp file ? Is this bad?

I made this Button.h

#include <SFML/Graphics/Texture.hpp>
#include <SFML/Graphics/Sprite.hpp>
#include <string>
#include <SFML/Window/Event.hpp> 



namespace Game {
    class Button : public sf::Sprite
    {
    private:
    bool isactive;
    public: 
        Button(sf::Texture texture);
        void listen(void (*callback)(), sf::Event);

    };
}

And Button.cpp


#include "Button.h"
#include <SFML/Window/Mouse.hpp>

using namespace Game;

    //for defines
    Button::Button(sf::Texture t) : sf::Sprite(t) {
        isactive = true;
    };

    void Button::listen(void (*callback)(),sf::Event e) {
        if (isactive && e.type == sf::Event::EventType::MouseLeft && this->getGlobalBounds().intersects(sf::Rect<float>(sf::Mouse::getPosition().x, sf::Mouse::getPosition().y, sf::Mouse::getPosition().x + 1, sf::Mouse::getPosition().y + 1)))
            callback();


    }


0 Answers