我正在尝试在Linux上用C++创建一个共享类库.我能够编译库,我可以使用我在这里和这里找到的教程调用一些(非类)函数.当我尝试使用库中定义的类时,我的问题开始了.我链接的第二个教程展示了如何加载符号来创建库中定义的类的对象,但是没有使用这些对象来完成任何工作.
Does anyone know of a more complete tutorial for creating shared C++ class libraries that also shows how to use those classes in a separate executable? A very simple tutorial that shows object creation, use (simple getters and setters would be fine), and deletion would be fantastic. A link or a reference to some open source code that illustrates the use of a shared class library would …
我有一个带有常量静态变量a的基类A. 我需要B类的实例对静态变量a有不同的值.如何实现这一点,最好是使用静态初始化?
class A {
public:
static const int a;
};
const int A::a = 1;
class B : public A {
// ???
// How to set *a* to a value specific to instances of class B ?
};
Run Code Online (Sandbox Code Playgroud)