Why following statement is not a "forward declaration"? :(
class namespace1::namespace2::class1; 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
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/
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
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/
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
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.
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.
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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...
|
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.
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
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: 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...
| |
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...
|
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...
|
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 ...
| |