By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,111 Members | 1,385 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,111 IT Pros & Developers. It's quick & easy.

friend+namespace

P: n/a
Dear all,
I have the following concept

name {

space1 {

class Friend {

};

};

};

name {

space2 {

MyClass {

friend name::space1::Friend;

};

};

};

For some reason I get Error: class, struct, union or type name::space1
not defined (in the line with the friend declaration). I think I am
missing something simple. Any ideas? Should I #include the Friend.h file
in any case? I would like to avoid this. Thanks,

filimon
Mar 20 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 20 Mar, 13:13, Filimon Roukoutakis <fili...@phys.uoa.grwrote:
Dear all,
I have the following concept

name {

space1 {

class Friend {

};
};
};

name {

space2 {

MyClass {

friend name::space1::Friend;

};
};
};

For some reason I get Error: class, struct, union or type name::space1
not defined (in the line with the friend declaration). I think I am
missing something simple. Any ideas? Should I #include the Friend.h file
in any case? I would like to avoid this. Thanks,
Except for the fact that the above code does not declare any
namespaces (missing the namespace keyword) I think you have to add ::
in front of name::space1::Friend since you otherwise try to access a
class in ::name::space2::name::space1 or some such.

--
Erik Wikström

Mar 20 '07 #2

P: n/a
Erik Wikström wrote:
On 20 Mar, 13:13, Filimon Roukoutakis <fili...@phys.uoa.grwrote:
>Dear all,
I have the following concept

name {

space1 {

class Friend {

};
};
};

name {

space2 {

MyClass {

friend name::space1::Friend;

};
};
};

For some reason I get Error: class, struct, union or type name::space1
not defined (in the line with the friend declaration). I think I am
missing something simple. Any ideas? Should I #include the Friend.h file
in any case? I would like to avoid this. Thanks,

Except for the fact that the above code does not declare any
namespaces (missing the namespace keyword) I think you have to add ::
in front of name::space1::Friend since you otherwise try to access a
class in ::name::space2::name::space1 or some such.

--
Erik Wikström
Unfortunately I get the same Error class, struct, union or type
::name::space1 not defined.
Mar 20 '07 #3

P: n/a

Filimon Roukoutakis <fi*****@phys.uoa.grwrote in message...
Erik Wikström wrote:
On 20 Mar, 13:13, Filimon Roukoutakis <fili...@phys.uoa.grwrote:
Dear all,
I have the following concept

name{
space1{
class Friend{};
};
};

name{
space2{
MyClass{
friend name::space1::Friend;
};
};
};

For some reason I get Error: class, struct, union or type name::space1
not defined (in the line with the friend declaration). I think I am
missing something simple. Any ideas? Should I #include the Friend.h
file
in any case? I would like to avoid this. Thanks,
Except for the fact that the above code does not declare any
namespaces (missing the namespace keyword) I think you have to add ::
in front of name::space1::Friend since you otherwise try to access a
class in ::name::space2::name::space1 or some such.
- - Erik Wikström

Unfortunately I get the same Error class, struct, union or type
::name::space1 not defined.
namespace name1{
namespace space1{
class Friend{};
}
}

namespace name1{ // add to name1
namespace space2{
class MyClass{
// friend class name1::space1::Friend;
friend class space1::Friend;
};
}
}

--
Bob R
POVrookie
Mar 21 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.