A
Alex Vinokur
I want static functions of classes Uam and Bar to be friends of class
Foo.
There is no problem with Uam::uam().
But class Bar has a member of Foo type: member Bar::m_foo, so one can't
put Bar definition before Foo definition.
As a result, a compiler rejects
friend void Bar::bar(); // in class Foo
Is there any solution for this problem?
------ foo.cpp ------
class Uam
{
static void uam() {}
};
class Bar;
class Foo
{
friend void Uam::uam();
friend void Bar::bar();
};
class Bar
{
Foo m_foo;
static void bar() {}
};
int main()
{
return 0;
}
---------------------
------ Compilation ------
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for
80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
foo.cpp
foo.cpp(11) : error C2027: use of undefined type 'Bar'
foo.cpp(6) : see declaration of 'Bar'
-------------------------
Thanks,
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn
Foo.
There is no problem with Uam::uam().
But class Bar has a member of Foo type: member Bar::m_foo, so one can't
put Bar definition before Foo definition.
As a result, a compiler rejects
friend void Bar::bar(); // in class Foo
Is there any solution for this problem?
------ foo.cpp ------
class Uam
{
static void uam() {}
};
class Bar;
class Foo
{
friend void Uam::uam();
friend void Bar::bar();
};
class Bar
{
Foo m_foo;
static void bar() {}
};
int main()
{
return 0;
}
---------------------
------ Compilation ------
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for
80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
foo.cpp
foo.cpp(11) : error C2027: use of undefined type 'Bar'
foo.cpp(6) : see declaration of 'Bar'
-------------------------
Thanks,
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn