【发布时间】:2012-02-04 15:21:31
【问题描述】:
我在命名空间内创建了一个类,现在当我必须使用或调用命名空间时出现问题,编译器错误的可能原因是什么?
namespace name1
{
class show
{
int a,b;
void accept_data(void);
void display_data(void);
friend void use_class(void);
};
}
编译器错误 -
test1.cpp:在函数“void use_class()”中:
test1.cpp:17:6: 错误:‘void name1::show::accept_data()’是私有的
test1.cpp:31:16: 错误:在此上下文中
test1.cpp:24:6: 错误:‘void name1::show::display_data()’是私有的
test1.cpp:32:17: 错误:在这个上下文中
【问题讨论】:
-
use_class声明在哪里? -
在命名空间外声明
-
你需要告诉我们编译器错误是什么
-
如果我删除命名空间,那么同样的程序运行起来非常容易
标签: c++ namespaces friend-function