friend+namespace

  • Thread starter Filimon Roukoutakis
  • Start date
F

Filimon Roukoutakis

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
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

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.
 
F

Filimon Roukoutakis

Erik said:
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.

Unfortunately I get the same Error class, struct, union or type
::name::space1 not defined.
 
B

BobR

Filimon Roukoutakis said:
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;
};
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top