Access another library (dll) which has same class name and method name

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 :

Total.h :
class Total
{
public:
static void Test(double);
}

Total.cpp :

static void Total::Test(double val)
{
...
}


Lib 2 :

Total.h :

class Total
{
public:
static void Test();
}

Total.cpp:

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 ?
Method 1
Each library should define its public stuff in its own namespace. That's it.

Method 2
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.
Last edited on
Topic archived. No new replies allowed.