您的位置:首页 > 产品设计 > UI/UE

Question #15: Which of the following functions are found when called in main during name lookup?

2009-05-11 17:06 651 查看
Question #15: Which of the following functions are found when called in main during name lookup?

55% on 10310 times asked

#include <iostream>
namespace standards
{
struct datastructure
{
};
void foo(const datastructure& ds)
{
}
void bar()
{
}
}
int main(int argc, char** argv)
{
standards::datastructure ds;
foo(ds);
bar();
return 0;
}


foo - correct
bar
foo and bar
neither
description: This is called koenig lookup or argument dependent name lookup. In this case, the namespace 'standards' is searched for a function 'foo' because its argument 'ds' is defined in that namespace. For function 'bar', no additional namespaces are searched and the name is not found. More details are in 3.4.2.

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐