C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Forward decleration of enumerations and typedefs in a NameSp

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
kasiyil
Guest





PostPosted: Mon Aug 21, 2006 9:10 am    Post subject: Forward decleration of enumerations and typedefs in a NameSp Reply with quote



Hello,
I have a compilation problem about namespaces:

I have a namespace X in which I declera a type definition:

In X.h file i write:

namespace X {
typedef unsigned int WindowHandle_t;
}

In a class which is in a different namespace ( Y ), I must use the type
definition I declared in namespace X.
MyClass.h file:

Y::MyClass {
....
private:
X::WindowHandle_t handle;
....
}

And the code doesn't compile. I should forward declare this handle type
definition but forward decleration is the same as writing the same
thing that I wrote in X.h file. When I write

In MyClass.h file :

namespace X {
typedef unsigned int WindowHandle_t;
}


Y::MyClass {
....
private:
X::WindowHandle_t handle;
....
}

The code compiles. But as I stated, I do not want to write same type
definition twice in a code. Do you have any suggestions?

Thanks...
Back to top
Ian Collins
Guest





PostPosted: Mon Aug 21, 2006 9:10 am    Post subject: Re: Forward decleration of enumerations and typedefs in a Na Reply with quote



kasiyil wrote:
Quote:
Hello,
I have a compilation problem about namespaces:

I have a namespace X in which I declera a type definition:

In X.h file i write:

namespace X {
typedef unsigned int WindowHandle_t;
}

In a class which is in a different namespace ( Y ), I must use the type
definition I declared in namespace X.
MyClass.h file:

Y::MyClass {
....
private:
X::WindowHandle_t handle;
....
}

And the code doesn't compile. I should forward declare this handle type
definition but forward decleration is the same as writing the same
thing that I wrote in X.h file. When I write

Have you included X.h?


--
Ian Collins.
Back to top
kasiyil
Guest





PostPosted: Mon Aug 21, 2006 9:11 am    Post subject: Re: Forward decleration of enumerations and typedefs in a Na Reply with quote



I included it after MyClass.h. There is no way to include it before
MyClass.h .

Ian Collins wrote:
Quote:
kasiyil wrote:
Hello,
I have a compilation problem about namespaces:

I have a namespace X in which I declera a type definition:

In X.h file i write:

namespace X {
typedef unsigned int WindowHandle_t;
}

In a class which is in a different namespace ( Y ), I must use the type
definition I declared in namespace X.
MyClass.h file:

Y::MyClass {
....
private:
X::WindowHandle_t handle;
....
}

And the code doesn't compile. I should forward declare this handle type
definition but forward decleration is the same as writing the same
thing that I wrote in X.h file. When I write

Have you included X.h?

--
Ian Collins.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.