Hi, I'm new to C++. Here is my scenario. I have 2 c++ libraries called "Lib1" and "Lib2". Both libraries have same class called "Total.h and Total.cpp"
I want to access lib1 class in lib2. since it has same class (i.e same header file), i couldn't refer lib1's members in lib2.
Lib 1 :
static void Test(double);
static void Total::Test(double val)
Lib 2 :
static void Test();
static void Total::Test()
// here i want to access Test(double val) method of Total from Lib1
Test(12); // something like this
Could you guys guide me how to access another library which has same name and how to add header file ?
Each library should define its public stuff in its own namespace. That's it.
1. You need to load them at runtime (rather than program load time).
2. The header files should define an interface, not the concrete implementation class.
3. You should define a factory function that creates the object and returns a pointer to it.
4. That means the interface should define a destroy method that releases the object.
5. You export the factory function and nothing else.
6. At runtime you load the library (LoadLibrary), get the address of the factory (GetProcAddress), then call the factory function to create an instance of the object.