On 2016-05-31 13:41, Emil Dotchevski wrote:
On Sun, May 29, 2016 at 10:47 PM, Vladimir Batov < Vladimir.Batov@constrainttec.com> wrote:
On 2016-05-30 12:36, Emil Dotchevski wrote:
It's better to do it the C way: simply leave foo incomplete:
struct foo; foo * create_foo(); void destroy_foo( foo * ); void do_something( foo * );
The above is much improved using shared_ptr:
struct foo; shared_ptr<foo> create_foo(); void do_something( foo * );
... Polymorphism -- the snippets I provided are sufficient, virtual function calls work just fine. For example, in the CPP file you could define do_something (see above declaration) like so:
void do_something( foo * p ) { p->do_something(); //virtual } ...
Indeed. You right... Once we take the methods out to be free-standing functions, there is nothing left of the interface/proxy class but shared_ptr<foo>... I have to admit it never occurred to me... :-) Not sure if I am ready to do things your way :-) but you are most certainly correct. Thank you.