You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
290 B

#include <iostream>
class OtherClass
{
public:
int i;
OtherClass() : i(5) {
}
OtherClass* self() {
return this;
}
};
class MyClass
{
public:
OtherClass x;
int getI();
};
int MyClass::getI() {
return this->x.self()->i;
}
int main() {
MyClass c;
std::cout << c.getI() << std::endl;
}