mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 22:02:49 -06:00
36 lines
449 B
C++
36 lines
449 B
C++
#include <iostream>
|
|
|
|
struct Base {
|
|
int x;
|
|
int y;
|
|
};
|
|
|
|
struct Derived : Base {};
|
|
/*
|
|
struct Foo {
|
|
int a;
|
|
int b;
|
|
|
|
operator Bar() const;
|
|
};
|
|
|
|
struct Bar : Foo {
|
|
};
|
|
|
|
Foo::operator Bar() const { return *(Bar *)this; }
|
|
*/
|
|
void Do(Base& a)
|
|
{
|
|
Derived b = *(Derived *)&a;
|
|
std::cout << b.x << ", " << b.y << '\n';
|
|
}
|
|
|
|
int main(int argc, const char **argv)
|
|
{
|
|
Derived f;
|
|
f.x = 12345;
|
|
f.y = 54321;
|
|
Do(f);
|
|
|
|
return 0;
|
|
}
|