Hi,
the following code produces errors with VC++ and Comeau, but compiles
with g++:
#include <iostream>
namespace n
{
struct c
{
void test();
private:
struct s
{
int i;
};
friend void f(s t);
};
}
void n::c::test()
{
s t = {42};
f(t);
}
void n::f(c::s t)
{
std::cout << t.i << std::endl;
}
int main()
{
n::c().test();
}
comeau prints:
error: namespace "n" has no member "f"
vc++ prints:
error C2248: 'n::c::s' cannot access private struct declared in class 'n::c'
both point to the line 'void n::f(c::s t)'.
If I write:
namespace n
{
void f(c::s t)
{
std::cout << t.i << std::endl;
}
}
instead, everything works fine.
What is wrong with the first version?
Thanks in advance
--
Sebastian Pfützner
s.pfuetzner@onl inehome.de
ICQ-ID: 39965036
the following code produces errors with VC++ and Comeau, but compiles
with g++:
#include <iostream>
namespace n
{
struct c
{
void test();
private:
struct s
{
int i;
};
friend void f(s t);
};
}
void n::c::test()
{
s t = {42};
f(t);
}
void n::f(c::s t)
{
std::cout << t.i << std::endl;
}
int main()
{
n::c().test();
}
comeau prints:
error: namespace "n" has no member "f"
vc++ prints:
error C2248: 'n::c::s' cannot access private struct declared in class 'n::c'
both point to the line 'void n::f(c::s t)'.
If I write:
namespace n
{
void f(c::s t)
{
std::cout << t.i << std::endl;
}
}
instead, everything works fine.
What is wrong with the first version?
Thanks in advance
--
Sebastian Pfützner
s.pfuetzner@onl inehome.de
ICQ-ID: 39965036
Comment