#include <SFML/Graphics.hpp>
int main() {
{
sf::CircleShape* cs = new sf::CircleShape(50);
cs->setFillColor(sf::Color::Green);
void* t = cs;
void* d = cs;
sf::RenderWindow window(sf::VideoMode(640, 640), "SFML Test");
// game loop
while (window.isOpen()) {
// events
sf::Event event;
while (window.pollEvent(event))
{
switch (event.type)
{
case sf::Event::Closed:
window.close();
break;
default:
break;
}
}
static_cast<sf::Transformable*>(t)->move(0.1, 0.1);
window.clear();
window.draw(*static_cast<sf::Drawable*>(d));
window.display();
}
delete cs;
}
return 0;
}
#include <iostream>
class Base {
public:
virtual void foo() {
std::cout << "Foo base" << std::endl;
}
};
class Derived : Base {
public:
void foo() {
std::cout << "Foo derived" << std::endl;
}
};
int main(){
auto ptr = new Derived();
void* vp = ptr;
static_cast<Base*>(vp)->foo();
delete ptr;
std::getchar(); // Windows user
return 0;
}