0

Text のメンバーを持つクラス内にクラスがありますが、これらのエラーが発生します。

Error   1   error C2146: syntax error : missing ';' before identifier 'text'    
Error   2   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   

どちらも構造体 MenuItem 内のテキスト テキスト行にあります。

ここに Menu.h があります: ここに MenuItem があります

#pragma once

#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <Source/Text/Text.h>
#include <list>

class Menu {

    public:
        static enum MenuResult { Exit, Options, Back, ChangeResolution, Play, Nothing };

        MenuResult showMMenu(sf::RenderWindow &window);
        MenuResult showOMenu(sf::RenderWindow &window);
        MenuResult highlightButton(MenuResult menuresult);

        struct MenuItem {
            public:
                Text text;
                sf::FloatRect buttonrect;
                static void highlightRectOutline(sf::RenderWindow &window, Text text, sf::Color color);
                MenuResult action;
        };

    private:
        MenuResult getMenuResponse(sf::RenderWindow &window);
        MenuResult handleClick(int x, int y);
        MenuResult handleButtonHover(sf::RenderWindow &window, int x, int y);
        std::list<MenuItem> menuItems;

};

Text.h: ここで、MenuItem が Text を取得します。

#pragma once

#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

enum style { bold, italic, underlined };

class Text {

    public: 
        void create(sf::RenderWindow &window,
                    char* string, 
                    char* fontpath, 
                    float positionx, 
                    float positiony,
                    unsigned int size,
                    style textstyle,
                    sf::Color color);

        sf::FloatRect getRect();
        static float getHeight();
        static float getWidth();

        bool operator==(Text t);
        bool operator!=(Text t);

        void setString(sf::RenderWindow &window, char* string);
        sf::String getString();

        void setFont(sf::RenderWindow &window, char* fontpath);
        sf::Font getFont();

        void setPosition(sf::RenderWindow &window, float x, float y);
        static sf::Vector2f getPosition();  

        void setScale(sf::RenderWindow &window, float x, float y);
        sf::Vector2f getScale();

        void setColor(sf::RenderWindow &window, int red, int green, int blue, int alpha);
        sf::Vector3i getColor();

    private:
        static sf::Text text;
        sf::Font font;
};
4

1 に答える 1

1

のこの行Text.h:

static sf::Text text;

Textは名前空間で宣言されてsfいないため、この名前は存在しません。

そのはず:

static Text text;
于 2013-02-03T22:00:07.060 に答える