I found a confusing thing about the "using" keyword. If I do using a class or struct, then it won't be necessary to do using functions in the same namespace which take that class or struct as an argument. Like the codes below.
namespace A
{
struct testData
{
int x;
};
int testFunc(testData data)
{
return data.x;
}
}
#include <cstdio>;
using A::testData;
int main()
{
testData test = { 1 };
printf("%d", testFunc(test));
return 0;
}
I thought I should not be allowed to use testFunc() because I only use the "using" keyword for testData. However, these codes work just fine.
Could you please tell me why this works this way?