1

this is 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;
}

this is 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);
        }
    }

};

the error prints this

Severity Code Description Project File Line Suppression State Error C2280 'sf::RenderWindow::RenderWindow(const sf::RenderWindow &)': attempting to reference a deleted function sfml C:\Users\Luka\Desktop\progrraming\sfml\sfml\sfml.cpp 19

thank you in advance

JustCode
  • 463
  • 2
  • 11
  • 2
    Your `house::init()` takes an `sf::RenderWindow` *by value*. However, `sf::RenderWindow` is **not copyable**. You can pass it by reference instead. – JFMR Nov 19 '20 at 18:51
  • 2
    Change `sf::RenderWindow window2` to `sf::RenderWindow & window2` – drescherjm Nov 19 '20 at 18:52
  • Does this answer your question? [use of deleted function ‘sf::RenderWindow& sf::RenderWindow::operator=(const sf::RenderWindow&)’](https://stackoverflow.com/questions/31444949/use-of-deleted-function-sfrenderwindow-sfrenderwindowoperator-const-sf) – alter_igel Nov 19 '20 at 18:55
  • Unrelated: Down at the bottom of Visual Studio near the Error List tab you'll find the Output tab. The Output tab contains the complete and unadulterated build output. it is plain text, making it really easy to paste into a Stack Overflow question while maintaining the formatting. As an added bonus because it doesn't leave stuff out to look pretty in a GUI, it contains much more information and often contains a few hints about how to resolve the problem. – user4581301 Nov 19 '20 at 18:56

0 Answers0