0

I'm new to C++ and I'm not understanding this (for me) strange behaviour.

#include <iostream>

namespace A {
    struct S {};
    int bar(S s) { return 1; };
}

int main() {
    A::S s;
    std::cout << bar(s);
}

This program compile withour errors, and prints 1... but my knowledge will says that an error should be thrown, something like "bar" is not defined; because it's is in A namespace.

How this could be possible?

Thank you.

kopiro
  • 689
  • 4
  • 11

0 Answers0