What will be called when calling the callFunc method of the obj object:
template <class X> void func(X val) { }
template <> void func<double>(double val) { }

class A
        void callFunc() { func(4.5); }
        void func(int val) { }
The compiler finds an element named func in the A class namespace, so it stops the search. An element named func in the A class does not have to be a function - it can be a regular class member. There can be many such elements - for example, an overloaded function. Next, the compiler searches for the most appropriate function among the found elements with the same name, which can be called with these arguments without converting the types of arguments or with an implicit conversion of the type of arguments of the function. In this case, it is void A::func(int); See also C++ lookup rules.

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Зареєструйся Зараз
або Підпишись на майбутні тести