How do you assign the index values to the static variable type of structure in class c++?)



  • #ifndef PALETTE_HPP
    #define PALETTE_HPP
    
    #include "coreMinimal.hpp"
    
    namespace kp
    {
        using stateColor_t = kp::Palette::StateColor;
    
        class Palette
        {
        public:
            struct StateColor
            {
                sf::Color shape;
                sf::Color outline;
                sf::Color text;
                sf::Color marker;
            };
    
            static const kp::stateColor_t* m_active;
            static const kp::stateColor_t* m_inactive;
        };
    }
    
    #endif // !PALETTE_HPP
    


  • Got a decision.

    Palette.hpp:

    #ifndef PALETTE_HPP
    #define PALETTE_HPP
    

    #include "coreMinimal.hpp"

    namespace kp
    {
    struct StateColor
    {
    sf::Color shape;
    sf::Color outline;
    sf::Color superimposed;
    sf::Color text;
    sf::Color marker;
    };

    class Palette
    {
    public:
        static const kp::StateColor* m_active;
        static const kp::StateColor* m_inactive;
    };
    

    }

    #endif // !PALETTE_HPP

    Palette.cpp:

    #include "Palette.hpp"

    const kp::StateColor* kp::Palette::m_active = new kp::StateColor
    {
    sf::Color(0, 0, 0, 255),
    sf::Color(0, 0, 0, 255),
    sf::Color(0, 0, 0, 255),
    sf::Color(0, 0, 0, 255),
    sf::Color(0, 0, 0, 255)
    };

    const kp::StateColor* kp::Palette::m_inactive = new kp::StateColor
    {
    sf::Color(0, 0, 0, 255),
    sf::Color(0, 0, 0, 255),
    sf::Color(0, 0, 0, 255),
    sf::Color(0, 0, 0, 255),
    sf::Color(0, 0, 0, 255)
    };



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2