-
Too lazy to explain in detail
void Entity::render(sf::RenderTarget& target)
{
target.draw(this->entity);
}
0xC0000005: Access violation reading location 0x0000000000000000.
Render function in Window.cpp
this->entity->render(*this->window);
Window.h
-------------------------
sf::RenderWindow* window;
Entity* entity;
-
You're probably reading or writing to a nullptr.
Too lazy to explain in detail ;)
-
You're probably reading or writing to a nullptr.
Too lazy to explain in detail ;)
Could you explain?
-
You're probably reading or writing to a nullptr.
Too lazy to explain in detail ;)
void Entity::render(sf::RenderTarget& target)
{
this->setEntity();
target.draw(this->entity);
}
Nothing looks undefined and now i am seeing that error on setEntity() function
void MainWindow::render()
{
this->setVariables();
this->window->clear(this->gray);
this->window->draw(this->posText);
this->entity->render(*this->window);
this->window->display();
}
-
"Access violation reading location 0x0000000000000000" means the program is trying to read from location 0 in memory, which isn't allowed. This is typically caused by using a pointer which is null.
If you run the program in a debugger, it should stop on the actual location of the null dereference. The code you provided might not actually be where things are failing (if it is, then probably either window or entity are null).
-
"Access violation reading location 0x0000000000000000" means the program is trying to read from location 0 in memory, which isn't allowed. This is typically caused by using a pointer which is null.
If you run the program in a debugger, it should stop on the actual location of the null dereference. The code you provided might not actually be where things are failing (if it is, then probably either window or entity are null).
The address is now static
Access violation reading location 0x0000000000000108.
And i am sure that the problem is Entity
(https://i.imgur.com/dS1Dggs.png)
-
Yep, the Entity pointer there (the "this" value) is null.
Maybe the code that set it up wasn't called, or something failed.
Values of pointers close to 0 (like 0x0000000000000108) are still from a null pointer. It's using the null as the base address of an object that doesn't exist, then offsetting from that to find member variables (resulting in the error at a near 0 value).
-
Yep, the Entity pointer there (the "this" value) is null.
Maybe the code that set it up wasn't called, or something failed.
Values of pointers close to 0 (like 0x0000000000000108) are still from a null pointer. It's using the null as the base address of an object that doesn't exist, then offsetting from that to find member variables (resulting in the error at a near 0 value).
Yeah i fixed that by making a function that initializes Entity
void MainWindow::initializeEntity(Entity& entity)
{
this->entity = &entity;
}