Defining interface of abstract class in shared library
问题 Say I have a abstract base class defined like so: interface.hpp #ifndef INTERFACE_HPP #define INTERFACE_HPP 1 class interface{ public: virtual void func() = 0; }; #endif // INTERFACE_HPP Then I compile a translation unit test.cpp into a shared object test.so : test.cpp #include "interface.hpp" #include <iostream> class test_interface: public interface{ public: void func(){std::cout << "test_interface::func() called\n";} }; extern "C" interface &get_interface(){ static test_interface test;