# Repair the problem in OverridingAmbiguity.cpp, first with scope resolution, then instead with a using declaration that forces the compiler to choose one of the identical function names.
all right. here is the code:
NamespaceMath.h :
Code: Select all
#ifndef NAMESPACEMATH_H
#define NAMESPACEMATH_H
#include "NamespaceInt.h"
namespace Math {
using namespace Int;
Integer a, b;
Integer divide(Integer, Integer);
// ...
}
#endif // NAMESPACEMATH_H ///:~
Code: Select all
#ifndef NAMESPACEOVERRIDING2_H
#define NAMESPACEOVERRIDING2_H
#include "NamespaceInt.h"
namespace Calculation {
using namespace Int;
Integer divide(Integer, Integer);
// ...
}
#endif // NAMESPACEOVERRIDING2_H ///:~
Code: Select all
#include "NamespaceMath.h"
#include "NamespaceOverriding2.h"
void s() {
using namespace Math;
using namespace Calculation;
// Everything's ok until:
Math::divide(1, 2); // Ambiguity
}
int main() {}
Code: Select all
cd /home/sergey/work/c++/tasks/c10/
make -k OverridingAmbiguity
g++ -oOverridingAmbiguity OverridingAmbiguity.o
OverridingAmbiguity.o(.text+0x50): In function `s()':
: undefined reference to `Math::divide(Int::Integer, Int::Integer)'
collect2: ld returned 1 exit status
make: *** [OverridingAmbiguity] 1
Compilation exited abnormally with code 2 at Sun Jan 16 12:48:45
pls help, or my braing just blows away.
PS sorry for bad english :-)

