How do I access functions via a unique pointer pointing on an object of that class
struct foo
{
foo(int);
void getY();
};
int main()
{
foo f1(1);
f1.getY();
std::unique_ptr<foo> ptr1 = make_unique<foo>(2);
*ptr1.getY(); // Error
};
foo has a constructor with an int as argument,getY() just prints out that int value.
Obviously foo f1(1); f1.getY(); works but idk how to access getY() over the pointer. unique_ptr<foo> ptr1 = make_unique<foo>(2); *ptr1.getY();
was my initial idea, but it doesn't work.