1

这是 main.cpp

#include <SFML/Graphics.hpp>
#include <iostream>
#include<windows.h>
#include <string>
#include "class.cpp"

using namespace sf;

int main()
{
    HWND hwnd = GetConsoleWindow();
    ShowWindow(hwnd, 0);
    RenderWindow window(sf::VideoMode(800, 450), "file", sf::Style::Close | sf::Style::Titlebar);
    //objects
    house ho;
    //end objects

    //inits
    ho.init(10,10,10,window);

    //end inits
    while (window.isOpen()) 
    {
        
        window.clear(sf::Color::Black); //clear screan with black

        sf::Event evnt;
        while (window.pollEvent(evnt)) 
        {
            if (evnt.type == evnt.Closed)
            {
                window.close();
            }
        }
        //draw
        

        //end draw
        window.display(); // display everything

    }
    return 0;
}

这是class.cpp

#include <SFML/Graphics.hpp>


class house {
private:
    float rx, ry, rpop;
public:

    void init(float x, float y, float pop,sf::RenderWindow window2) {
        bool inittrue = false;
        rx, ry, rpop = x, y, pop;
        if (pop > 0) {
            inittrue = true;
        }
        if (inittrue == true) {
            sf::RectangleShape rectangle(sf::Vector2f(50.f, 40.f));
            rectangle.setPosition(sf::Vector2f(x, y));
            window2.draw(rectangle);
        }
    }

};

错误打印这个

严重性代码 描述 项目文件行抑制状态错误 C2280 'sf::RenderWindow::RenderWindow(const sf::RenderWindow &)': 试图引用已删除的函数 sfml C:\Users\Luka\Desktop\progrraming\sfml\sfml\ sfml.cpp 19

先感谢您

4

0 回答 0