SH
Size: a a a
SH
Y
SH
AB
AM
SH
AM
AM
SH
SH
AM
AM
SH
d
SH
d
struct Base {
virtual int foo () = 0;
};
struct Heir : Base {
int foo() { return 0; }
};
int main() {
std::unique_ptr<Base> ptr(new Base());
}
AM
class IMyInterface {
public:
virtual void SomeMethod(void) = 0;
};
class MyClass : public IMyInterface {
void SomeMethod(void) {
}
};
unique_ptr<IMyInterface> GetInterface(void)
{
auto instance = unique_ptr<MyClass>(new MyClass);
return instance;
}
main()
{
auto interface = GetInterface();
interface->SomeMethod(); <<<<<<<<< Чо будет?
}
d
class IMyInterface {
public:
virtual void SomeMethod(void) = 0;
};
class MyClass : public IMyInterface {
void SomeMethod(void) {
}
};
unique_ptr<IMyInterface> GetInterface(void)
{
auto instance = unique_ptr<MyClass>(new MyClass);
return instance;
}
main()
{
auto interface = GetInterface();
interface->SomeMethod(); <<<<<<<<< Чо будет?
}
AM
SH
class IMyInterface {
public:
virtual void SomeMethod(void) = 0;
};
class MyClass : public IMyInterface {
void SomeMethod(void) {
}
};
unique_ptr<IMyInterface> GetInterface(void)
{
auto instance = unique_ptr<MyClass>(new MyClass);
return instance;
}
main()
{
auto interface = GetInterface();
interface->SomeMethod(); <<<<<<<<< Чо будет?
}
unique_ptr<IMyInterface> GetInterface(void)
{
return std::make_unique<MyClass>();
}