hello,
Thanks a lot to Hielke. ( how do you pronounce it? :)
)
I prefer that Dev-C++ does all my project file
management. So I guess I should try to be less lazier.
Your way of using "internal headers" is cool though.
Siva Chandra
--- Hielke <hie...@he...> wrote:
> AFAIK there is no way you could safely use
> usingstatements in your
> header files. So AVOID it (As you did mention by
> yourself it is not very
> kind to force users of your code to use namespaces
> they did not declare
> themselves)! Just try to be a somewhat less lazier
> :o).
> However there are neat ways using those in your
> member implementations.
> Personally I'd like to use internal header files for
> that purpose.
> Including an 'in-between-headerfile' from your
> source code which
> includes the actual classdefinition headerfile. My
> code organization
> then looks as follows:
>
> // member1.cc
> #include "classa.ih" // include internal header,
> note the "i"
>
> void Member1()
> {
> }
>
> // classa.ih
> #include "classa.h" // include actual definition
> header
>
> /* Includes, namespacedeclarations, etc. for your
> sourcefiles here*/
> using namespace blabla;
>
> // classa.h
> #ifndef _CLASSA_H_
> #define _CLASSA_H_
>
> class A
> {
> ...
> void Member1();
> };
>
> #endif
>
> This approach however has one big disadvantage. In
> IDE's such as Dev-CPP
> you have to include those files in the linking
> process manually since
> Dev-CPP doesn't recognize the ".ih" (or whatever
> you'd like to use for
> internal headers) extension.
>
> Regards,
> Hielke
>
>
> Siva Chandra wrote:
>
> >hello all,
> >
> >I have a question on using namespaces. Say I want
> to
> >build a class ClassA and put it in a namespace abc.
> >Then I would declare the class in a header file,
> >header1.h, like:
> >
> >#ifndef __HEADER1_H__
> >#define __HEADER1_H__
> >
> >namespace abc
> >{ // Start of namespace brace.
> >
> >class ClassA
> >{
> >...
> >};
> >
> >} // End of namespace brace.
> >
> >#endif // __HEADER1_H__
> >
> >Now I would like to include this header file in
> >another header file, header2.h. Here again I want
> to
> >declare a class ClassB under the same namespace
> abc.
> >This ClassB is inherited from ClassA. So to avoid
> >writing abc::ClassA everywhere I just say:
> >
> >using namespace abc;
> >
> >at the begining of the file. My file would be like:
> >
> >#ifndef __HEADER2_H__
> >#define __HEADER2_H__
> >
> >#include "header1.h"
> >
> >using namespace abc;
> >
> >namespace abc
> >{ // Start of namespace brace.
> >
> >class ClassB : public ClassA
> >{
> >...
> >};
> >
> >} // End of namespace brace.
> >
> >#endif // __HEADER2_H__
> >
> >My question is here: By explicitly putting a
> statement
> >like
> >
> >using namespace abc;
> >
> >I am including such a statement in all my code
> which
> >use this header file header2.h. Is there a way to
> >avoid such a thing from happening without losing
> the
> >functionality I want it to be there for? Or is it
> that
> >I am not using it in the right manner?
> >
> >Thanks a lot for having enough patience to read
> this
> >long,
> >
> >Siva Chandra.
> >
> >
> >
> >
> >_______________________________
> >Do you Yahoo!?
> >Win 1 of 4,000 free domain names from Yahoo! Enter
> now.
> >http://promotions.yahoo.com/goldrush
> >
> >
>
>-------------------------------------------------------
> >This SF.Net email is sponsored by BEA Weblogic
> Workshop
> >FREE Java Enterprise J2EE developer tools!
> >Get your free copy of BEA WebLogic Workshop 8.1
> today.
>
>http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
> >_______________________________________________
> >Dev-cpp-users mailing list
> >Dev...@li...
> >TO UNSUBSCRIBE:
> http://www23.brinkster.com/noicys/devcpp/ub.htm
>
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> >
> >
> >
>
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail
|