由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - frend func defined in class
相关主题
[合集] C++问题(copy constructor)c++ typedef 一问
pointer to functionCall assembly in c++ under linux
请教个virtual function的问题Global(static) variable initialization question
inline functions in C++a simple question for C++ class
cpp gz filewhich func will be called?
__FUNCTION__ 是怎么回事呀?[合集] 为什么不能: declare a static memeber func
??? i m confused一个简单的算法问题?
读取数据求教template metaprogramming 的问题
相关话题的讨论汇总
话题: func话题: class话题: friend话题: frend话题: void
进入Programming版参与讨论
1 (共1页)
j***i
发帖数: 1278
1
#include
class C
{
friend void func(){std::cout<<"friend func";}
};
//void func();

int main()
{
func();
}
注释掉后 func': candidate function(s) not accessible error,
加上就好了, 定义在non-local class 里的 friend class 应该和class 一个namespa
ce呀,不声明一下就出错了?
a****d
发帖数: 114
2
下面这个是work的:
//////////////////////////////
#include
class C
{
friend void f(C* c){}
};
int main()
{
f((C*)0);
return 0;
}
//////////////////////////////
大概和namespace还有Argument Dependent Lookup有关。我在看c++ primer, 但还没有
到namespace那里...

【在 j***i 的大作中提到】
: #include
: class C
: {
: friend void func(){std::cout<<"friend func";}
: };
: //void func();
:
: int main()
: {
: func();

1 (共1页)
进入Programming版参与讨论
相关主题
template metaprogramming 的问题cpp gz file
请问一个exception题目__FUNCTION__ 是怎么回事呀?
关于 VC++ vitual, reload 和 derive的一个问题...??? i m confused
ask a C++ inheritance question读取数据求教
[合集] C++问题(copy constructor)c++ typedef 一问
pointer to functionCall assembly in c++ under linux
请教个virtual function的问题Global(static) variable initialization question
inline functions in C++a simple question for C++ class
相关话题的讨论汇总
话题: func话题: class话题: friend话题: frend话题: void