Topic: namespaces (was main( ))
Author: Gerard Weatherby <gerardw@alum.mit.edu>
Date: 1997/04/15 Raw View
David R Tribble wrote:
> A namespace,
> by any other name, is just a wrapper class.
Not really. I've had the opportunity to use a compiler that supports
namespaces for a few months now.
A class has a single definition. The same namespace can be used in
multiple declarations and definitions.
Namespaces can be shortened be use of an alias; this doesn't seem to
cause the same weirdness that typedefs do. (See the thread on forward
declarations of template instantations for examples of "weirdness".)
A namespace can bring symbols from other namespaces into it.
I don't know of a class equivalent of using directives and declarations.
It's my opinion that related sets of functions that don't share data are
better modeled in a namespace ran than as classes.
> Oh, but I forgot, your single compiler supports
> namespaces while the eight or nine compilers we use don't.
Isn't the idea of a standard is that all compilers will move towards it,
not that the standard is supposed to define the least common denominator
of existing compilers?
> Not exactly. What happens when your operator<<() conflicts with a > third party's operator<<()? Or when your List class conflicts with > someone else's List class?
Generally, the operator's<< we define are overloaded on classes we
define, so there isn't a problem with a conflict with anyone elses. Our
List class doesn't conflict with someone's else's list class because it
IS in a namespace.
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]