Why following statement is not a "forward declaration"? :(
class namespace1::nam espace2::class1 ; 8 1928
v4vijayakumar wrote:
Why following statement is not a "forward declaration"? :(
class namespace1::nam espace2::class1 ;
Who knows? Try
namespace namespace1 { namespace namespace2 { class class1; } }
instead.
john
On Jun 20, 3:33 pm, v4vijayakumar <vijayakumar.su bbu...@gmail.co m>
wrote:
Why following statement is not a "forward declaration"? :(
class namespace1::nam espace2::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.comwr ote:
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.comwr ote:
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.comwr ote:
> 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.co mwrote:
Sarath wrote:
On Jun 20, 4:19 pm, John Harrison <john_androni.. .@hotmail.comwr ote:
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.co mwrote:
>Sarath wrote:
>>On Jun 20, 4:19 pm, John Harrison <john_androni.. .@hotmail.comwr ote: 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 Behind:
* Dim NewClass1 As New Namespace.Namespace2.Class1
|
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 same name the Visual Studio
NET IDE blocks my attempt and asks whether I want to overwrite the first
class. Which I do not want to do.
Compiling is fine outside the IDE.
|
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 in other classes.
I can make an aspx page reference a class Class1 in namespace
NameSpace1 using
<%@ Assembly Src="../App_Code/NameSpace1.vb" %>
I also have a class in another file called DBConn which is in
|
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 compiling with the IDE? I don't see a 'command line
options' field anywhere...???
| |
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |