473,396 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

friend+namespace

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
3 3468
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
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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Xavier Decoret | last post by:
The following code does not compoile with gcc-3.2.3 namespace dummy { //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Interface of Foo...
4
by: Hans De Winter | last post by:
Why does my compiler complain with the message "`int*My::Test::_shape' is private" when I try to compile the following code? It seems it has something to do with the namespace since when I leave...
4
by: marco_segurini | last post by:
Hi, the following test program shows a solution to a problem I have had. Now, this test program is compiled and linked by VS2003 and g++ while Comeau-on-line-compiler fails with this messages:...
9
by: Ivan Mascovich | last post by:
Previous posts (and compilers) confirm that class X { friend void Y() ; } ; does not match namespace
2
by: Layton | last post by:
Hi, CPP gurus, How to use friend function cross the namespace? I have the following sample code with operator << overloaded, it's working. The problem the operator << function can't access...
5
by: Steven T. Hatton | last post by:
This note appears in the discussion of name hiding and uniqueness: §3.3 #4 This note is item #6 in the discussion of "Point of declaration" §3.3.1 #6 What exactly do these statements mean?...
6
by: WaterWalk | last post by:
I find friend declaration just very tricky. I tried the following examples on both MingW(gcc 3.4.2) and VC++ 2005. The results are surprising. Example1: namespace ns1 { class Test { friend...
4
by: rn | last post by:
the code below compiles OK with gcc 4.0 but not with gcc.4.2 and visual studio 2005 (ver 8 ). to me it seems it should not compile. ----- class test1 { public:
14
by: =?ISO-8859-15?Q?Sebastian_Pf=FCtzner?= | last post by:
Hi, the following code produces errors with VC++ and Comeau, but compiles with g++: #include <iostream> namespace n { struct c
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.