473,499 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

class namespace1::namespace2::class1;

Why following statement is not a "forward declaration"? :(

class namespace1::namespace2::class1;

Jun 20 '07 #1
8 1915
v4vijayakumar wrote:
Why following statement is not a "forward declaration"? :(

class namespace1::namespace2::class1;
Who knows? Try

namespace namespace1 { namespace namespace2 { class class1; } }

instead.

john
Jun 20 '07 #2
On Jun 20, 3:33 pm, v4vijayakumar <vijayakumar.subbu...@gmail.com>
wrote:
Why following statement is not a "forward declaration"? :(

class namespace1::namespace2::class1;
Hmmm... hard to guess...

In your case, I fear the compiler could not resolve the namespace as
you are not including the file (probably the .h file) which has
defined the namespace. That's why the compiler shows error. AFAIK,
namespace can't be forward declared. If the namespace declaration
available, your code will be perfectly valid.

Regards,
Sarath
http://sarathc.wordpress.com/

Jun 20 '07 #3
If the namespace declaration
available, your code will be perfectly valid.
namespace x
{
namespace y
{
}
}

class x::y::c;

Errors

error C2039: 'c' : is not a member of 'x::y'
error C2365: 'x' : redefinition; previous definition was 'namespace'
error C2079: 'c' uses undefined class 'x'

john
Jun 20 '07 #4
On Jun 20, 4:19 pm, John Harrison <john_androni...@hotmail.comwrote:
If the namespace declaration
available, your code will be perfectly valid.

namespace x
{
namespace y
{
}

}

class x::y::c;

Errors

error C2039: 'c' : is not a member of 'x::y'
error C2365: 'x' : redefinition; previous definition was 'namespace'
error C2079: 'c' uses undefined class 'x'

john
In my Visual C++ 6.0 and 7.1 compiler the above statement is perfectly
valid. I'm not sure about other compilers.

Regards,
Sarath
http://sarathc.wordpress.com/

Jun 20 '07 #5
On Jun 20, 4:19 pm, John Harrison <john_androni...@hotmail.comwrote:
If the namespace declaration
available, your code will be perfectly valid.

namespace x
{
namespace y
{
}

}

class x::y::c;

Errors

error C2039: 'c' : is not a member of 'x::y'
error C2365: 'x' : redefinition; previous definition was 'namespace'
error C2079: 'c' uses undefined class 'x'

john
Ooops forgot the post the sample code
namespace x
{
namespace y
{

class CTest
{

};
}
}

class x::y::CTest;

This is it

Jun 20 '07 #6
Sarath wrote:
On Jun 20, 4:19 pm, John Harrison <john_androni...@hotmail.comwrote:
> If the namespace declaration
>>available, your code will be perfectly valid.
namespace x
{
namespace y
{
}

}

class x::y::c;

Errors

error C2039: 'c' : is not a member of 'x::y'
error C2365: 'x' : redefinition; previous definition was 'namespace'
error C2079: 'c' uses undefined class 'x'

john

Ooops forgot the post the sample code
namespace x
{
namespace y
{

class CTest
{

};
}
}

class x::y::CTest;

This is it
This isn't a forward declaration, John's was.

--
Ian Collins.
Jun 20 '07 #7
On Jun 20, 5:16 pm, Ian Collins <ian-n...@hotmail.comwrote:
Sarath wrote:
On Jun 20, 4:19 pm, John Harrison <john_androni...@hotmail.comwrote:
If the namespace declaration
>available, your code will be perfectly valid.
namespace x
{
namespace y
{
}
}
class x::y::c;
Errors
error C2039: 'c' : is not a member of 'x::y'
error C2365: 'x' : redefinition; previous definition was 'namespace'
error C2079: 'c' uses undefined class 'x'
john
Ooops forgot the post the sample code
namespace x
{
namespace y
{
class CTest
{
};
}
}
class x::y::CTest;
This is it

This isn't a forward declaration, John's was.

--
Ian Collins.
I was talking about the validity of the statement. Sorry if poorly
communicated.

Jun 20 '07 #8
Sarath wrote:
On Jun 20, 5:16 pm, Ian Collins <ian-n...@hotmail.comwrote:
>Sarath wrote:
>>On Jun 20, 4:19 pm, John Harrison <john_androni...@hotmail.comwrote:
If the namespace declaration
available, your code will be perfectly valid.
namespace x
{
namespace y
{
}
}
class x::y::c;
Errors
error C2039: 'c' : is not a member of 'x::y'
error C2365: 'x' : redefinition; previous definition was 'namespace'
error C2079: 'c' uses undefined class 'x'
john
Ooops forgot the post the sample code
namespace x
{
namespace y
{
class CTest
{
};
}
}
class x::y::CTest;
This is it
This isn't a forward declaration, John's was.

I was talking about the validity of the statement. Sorry if poorly
communicated.
I see, but the topic was forward declarations, for which the syntax
isn't valid. One has to use the containing namespace as shown in John's
original post.

Please don't quote signatures.

--
Ian Collins.
Jun 20 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1142
by: Jon Gonzales | last post by:
Item #1: Project Reference > DLLClass1 Project Properties > Imports > Namespace.Namespace2 - In Code Behind: * Dim NewClass1 As New Class1 Item #2: Project Reference > DLLClass1 - In Code...
4
5200
by: Jan Michalski | last post by:
Does anyone know how to incorporate classes with different namespaces within a project? I have two classes with the same name but different namespace. When I try to add the the second class of the...
6
7016
by: chrisd | last post by:
Heya, I might be going about this in completely the wrong fasion, I am more of a PHP developer, but I am trying to build a collection of classes in ASP.Net to implement in some aspx pages but also...
8
1108
by: John A Grandy | last post by:
what are the various alternatives to including a group of imports statements in every module ? imports <namespace1.class1> imports <namespace2.class1> imports <namespace2.class2> etc.
4
3510
by: bern11 | last post by:
How do you embed a custom cursor? The help says: // On the command line: // Add the following flag: // /res:CursorFileName.Cur,Namespace.CursorFileName.Cur What if you are...
0
7130
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
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6893
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
7386
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5468
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,...
1
4918
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3098
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.