0

I need to use the function from library (b.h) in a.cpp ,which already contains the function with same name.I have a condition where you can't change the names of functions.

a.cpp

#include "b.h"
class A{ 
void abc(){ 

    abc(); //this function needs to be from library (b.h) 
   } 
};

b.h

class b{
    public:
    void abc(); 
};

b.cpp

void b::abc(){
 //defination
}
aniket dhole
  • 91
  • 1
  • 7
  • i have refered this but it didn't help https://stackoverflow.com/questions/678254/what-should-i-do-if-two-libraries-provide-a-function-with-the-same-name-generati – aniket dhole May 21 '20 at 11:14
  • 2
    There is no ambiguity here, you need an instance of `B` to call `B::abc` (same for `A::abc`). (Like there are dozens of classes with `.size()` member functions - those don't cause any issue.) – Mat May 21 '20 at 11:16
  • 2
    You will also need an object of type `B` to call `B::abc` on. Since none of the two functions are free functions, there won't be problem or it's not clear what could be a problem here. – Lukas-T May 21 '20 at 11:21

0 Answers0