How does Name lookup work when using multiple inheritance in C++?

Why does the following work(I know it would not work when d.f(5)): #include <string> #include <iostream> struct A { int f(int a) { return a*a; } }; struct B : A { std::string f(std::string string) { return "Hello " + string; } }; struct Derived : B {}; int main() { Derived d; std::cout <<… Read More How does Name lookup work when using multiple inheritance in C++?

variables declaration in anonymous namespace and definition in other place

Can someone explain why I can’t define variable that was declared in anonymous namespace as global variable in another place? #include <iostream> namespace { extern int number; } int number = 123; void g() { std::cout << number; } Compiler says that "Reference to ‘number’ is ambiguous" but I can’t understand why it recognises declaration… Read More variables declaration in anonymous namespace and definition in other place