小编syp*_*lex的帖子

为什么命名空间中的某些函数可以在没有命名空间作用域前缀的情

命令空间中的函数是否只能通过使用命名空间作用域或using指令来访问?

我遇到一个问题,在命名空间内定义的某些函数可以访问该命名空间的OUTSIDE.我相信应该有一个编译器错误,但我没有在我尝试过的三个不同的编译器中得到一个(VS.NET 2003,VS2010和GCC 4).

这是代码:

namespace N{
  typedef struct _some_type *some_type;
  struct some_struct { int x; };
  void A(void);
  void B(int);
  void C(some_type*);
  void D(some_type);
  void E(struct some_struct);
}

using N::some_type;
using N::some_struct;

void TestFunction()
{
  some_type foo;
  some_struct s;

  N::A();         //should compile (and does on VS2003, VS2010, and GCC 4.1.2)
  ::A();          //shouldn't compile (and doesn't on VS2003, VS2010, and GCC 4.1.2)
  A();            //shouldn't compile (and doesn't on VS2003, VS2010, and GCC 4.1.2)

  N::B(0);        //should compile (and does on VS2003, …
Run Code Online (Sandbox Code Playgroud)

c++

7
推荐指数
1
解决办法
182
查看次数

Linux:用负面的pid杀死

来自SUSv4:

如果pid是负数,但不是-1,则应将sig发送到进程组ID等于pid绝对值的所有进程(不包括未指定的系统进程集),并且进程有权发送信号.

据我所知,任何时候都不能有2个或更多具有相同PID的进程.为什么规范要对所有流程说明?

谢谢.

c unix linux

2
推荐指数
2
解决办法
4349
查看次数

标签 统计

c ×1

c++ ×1

linux ×1

unix ×1