Here is an example of my code:
//Header file
#include <vector>
using std::vector;
namespace Revelation {
// class definitions, etc...
// class members are of type std::vector
}
//Source File
#include <header_file>
namespace Revelation {
// stuff that used std::vector here;
}
Now my question is: where should I put the #include<vector >, and where
should I put using std::vector ??? Both outside of my namespace? Include
outside and "using" inside? Both inside?
Thanks,
Martin 24 3478
On Sat, 6 Sep 2003 01:20:47 -0400, "Marcin Vorbrodt" <mv*****@eos.nc su.edu> wrote: Here is an example of my code:
//Header file #include <vector>
OK.
using std::vector;
Don't do that in a header file.
namespace Revelation { // class definitions, etc... // class members are of type std::vector }
//Source File #include <header_file> namespace Revelation { // stuff that used std::vector here; }
Now my question is: where should I put the #include<vector >,
OK as is.
and where should I put using std::vector ???
Not in the header file.
Before the code that uses 'std::vector' unqualified.
Let me be more specific...
Should the #unclude and using be inside my namespace or before it?
Martin
"Alf P. Steinbach" <al***@start.no > wrote in message
news:3f******** ********@News.C IS.DFN.DE... On Sat, 6 Sep 2003 01:20:47 -0400, "Marcin Vorbrodt"
<mv*****@eos.nc su.edu> wrote:Here is an example of my code:
//Header file #include <vector>
OK.
using std::vector;
Don't do that in a header file. namespace Revelation { // class definitions, etc... // class members are of type std::vector }
//Source File #include <header_file> namespace Revelation { // stuff that used std::vector here; }
Now my question is: where should I put the #include<vector >,
OK as is.
and where should I put using std::vector ???
Not in the header file.
Before the code that uses 'std::vector' unqualified.
On Sat, 6 Sep 2003 02:00:04 -0400, "Marcin Vorbrodt" <mv*****@eos.nc su.edu> wrote:
Answer: Because it messes up the order in which people normally read text.
Question: Why is top-posting such a bad thing?
Answer: Top-posting.
Question: What is the most annoying thing on Usenet? Let me be more specific... Should the #unclude and using be inside my namespace or before it?
Martin
"Alf P. Steinbach" <al***@start.no > wrote in message news:3f******* *********@News. CIS.DFN.DE... On Sat, 6 Sep 2003 01:20:47 -0400, "Marcin Vorbrodt" <mv*****@eos.n csu.edu> wrote: >Here is an example of my code: > >//Header file >#include <vector>
OK.
>using std::vector;
Don't do that in a header file. >namespace Revelation { > // class definitions, etc... > // class members are of type std::vector >} > > >//Source File >#include <header_file> >namespace Revelation { > // stuff that used std::vector here; >} > >Now my question is: where should I put the #include<vector >,
OK as is.
> and where should I put using std::vector ???
Not in the header file.
Before the code that uses 'std::vector' unqualified.
OK...
"Alf P. Steinbach" <al***@start.no > wrote in message
news:3f******** ********@News.C IS.DFN.DE... On Sat, 6 Sep 2003 02:00:04 -0400, "Marcin Vorbrodt"
<mv*****@eos.nc su.edu> wrote: Answer: Because it messes up the order in which people normally read
text. Question: Why is top-posting such a bad thing?
Answer: Top-posting.
Question: What is the most annoying thing on Usenet?
Let me be more specific... Should the #unclude and using be inside my namespace or before it?
Martin
"Alf P. Steinbach" <al***@start.no > wrote in message news:3f******* *********@News. CIS.DFN.DE... On Sat, 6 Sep 2003 01:20:47 -0400, "Marcin Vorbrodt" <mv*****@eos.n csu.edu> wrote: >Here is an example of my code: > >//Header file >#include <vector>
OK.
>using std::vector;
Don't do that in a header file. >namespace Revelation { > // class definitions, etc... > // class members are of type std::vector >} > > >//Source File >#include <header_file> >namespace Revelation { > // stuff that used std::vector here; >} > >Now my question is: where should I put the #include<vector >,
OK as is.
> and where should I put using std::vector ???
Not in the header file.
Before the code that uses 'std::vector' unqualified.
Marcin Vorbrodt wrote: OK...
Please don't top-post. It is bad Usenet etiquette. Re-read section 5 of
the FAQ for posting guidelines. You seem to have missed some points the
first time through. http://www.parashift.com/c++-faq-lite/
-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
> <Marcin Vorbrodt> " <mv*****@eos.nc su.edu> wrote in message Now my question is: where should I put the #include<vector >, and where should I put using std::vector ??? Both outside of my namespace? Include outside and "using" inside? Both inside? </Marcin Vorbrodt>
Namespace is a fairly useless feature since you drag all names back into the global namespace before you can use them. With some extra typing and an extra level of bugs.
The fact that you don't understand namespaces doesn't make them useless.
The only good thing about namespace is the global namespace :: It makes you feel like you are 'inside an object' when programming.
If you sincerely believe that is a good advice, you better stay far away
from large scale C++ projects and stick with "hello world" type of
applications. Considering that many programming languages offer a feature
similar to C++ namespaces should ring a bell though.
--
Peter van Merkerk
peter.van.merke rk(at)dse.nl
<Agent Mulder> The one good thing about namespace is the global namespace :: It makes you feel like you are 'inside an object' when programming.
</Agent Mulder>
<Peter van Merkerk> If you sincerely believe that is a good advice, you better stay far away from large scale C++ projects and stick with "hello world" type of applications. Considering that many programming languages offer a feature similar to C++ namespaces should ring a bell though.
</Peter van Merkerk>
Why not declare a class LargeScaleC++Pr oject with pointers
to (named) MiddleScaleC++P roject objects? With proper
design there is no need for namespace. If such thing were
introduced at all, it had been better to add file level support.
-X
Agent Mulder <mb************ *******@home.nl > wrote in message
news:bj******** **@news2.tilbu1 .nb.home.nl... <Marcin Vorbrodt> " <mv*****@eos.nc su.edu> wrote in message Now my question is: where should I put the #include<vector >, and where should I put using std::vector ??? Both outside of my namespace? Include outside and "using" inside? Both inside? </Marcin Vorbrodt>
Namespace is a fairly useless feature
Nonsense.
since you drag all names back into the global namespace before you can use them.
// the following uses a single name from namesspace
// 'std'. It puts no names at all in the 'global
// namespace' except the function name 'foo()'
#include <iostream>
void foo()
{
using std::cout;
cout << "you don't understand namespaces\n";
}
The following puts all names from namespace 'std'
in the scope of function 'foo()', and puts no names
in 'global scope' except the function name 'foo()'
#include <iostream>
void foo()
{
using namespace std;
cout << "you need to read about namespaces in a C++ book\n";
}
With some extra typing
One cannot use a language feature without expressing it.
This is done by typing. How else?
and an extra level of bugs.
What level of bugs? You mean those that are introduced
by folks who don't understand namespaces? The only good thing about namespace is the global namespace ::
What's good about it?
It makes you feel like you are 'inside an object' when programming.
And that's good because? What does it feel like to
be 'inside an object?'
-Mike
> <Agent Mulder> The one good thing about namespace is the global namespace :: It makes you feel like you are 'inside an object' when programming. </Agent Mulder>
<Peter van Merkerk> If you sincerely believe that is a good advice, you better stay far away from large scale C++ projects and stick with "hello world" type of applications. Considering that many programming languages offer a
feature similar to C++ namespaces should ring a bell though. </Peter van Merkerk>
Why not declare a class LargeScaleC++Pr oject with pointers to (named) MiddleScaleC++P roject objects?
If you have to ask that you are really clueless about namespaces and even
more so about large scale projects. Classes and namespaces address two very
different issues. A class LargeScaleC++Pr oject with pointers to
MiddleScaleC++P roject objects (to which instances are they pointing too???)
does something totally different than namespaces. It seems that you don't
know the difference between declaration and instantiation. In the days
namespaces were not commonly supported by C++ compilers sometimes a struct
was used to emulate namespaces (but not in the way you describe). However
that struct hack was a long trek from the real thing.
With proper design there is no need for namespace.
This has little to do with design. But if you never go beyond "hello world"
type applications namespaces are indeed a useless feature.
If such thing were introduced at all, it had been better to add file level support.
I don't know what you mean by that (it could mean just about anything), but
I guess the standardization commitee should invite you to their next
meeting.
--
Peter van Merkerk
peter.van.merke rk(at)dse.nl This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steven Bethard |
last post by:
In the "empty classes as c structs?" thread, we've been talking in some
detail about my proposed "generic objects" PEP. Based on a number of
suggestions, I'm thinking more and more that instead of a single
collections type, I should be proposing a new "namespaces" module
instead. Some of my reasons:
(1) Namespace is feeling less and less...
|
by: Mike Morse |
last post by:
What see sample that show xs:element where the xs namespace =
http://www.w3.org/2001/XMLSchema
However, I see another example with xsi: where xsi =
http://www.w3.org/2001/XMLSchema-instance
What's the difference here? Are there right and wrong namespaces? Is there
a global list of the ones to use? Does the namespace even need to point...
|
by: Jim Heavey |
last post by:
Trying to get the hang of Namespaces. I have primarly developed in VB and
am transitioning to C# and the .Net Environment. I have worked a bit with
Java as well in school about a year or so ago.
NameSpaces and Java Packages are similar in nature? In the dot net world,
you are not able to pick out (import) a particulare "class" within the...
|
by: clintonG |
last post by:
Using 2.0 with Master Pages and a GlobalBaseClass for the content pages.
I understand the easy part -- the hierarchical structure of a namespace
naming convention -- but the 2.0 IDE does not write a signature for the
developer and after getting a good start developing a 2.0 application I
thought I should go through the code and start marking...
|
by: Random |
last post by:
I'm confused about the proper use and usefulness of namespaces. I beleive I
understand the purpose is so the developer can put classes within namespaces
to essentially organize your code. And I understand that you declare your
intention to use a namespace within a page through the "Inherits" attribute.
I know that using "Inherits" isn't...
| |
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...
|
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...
|
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...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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...
| |
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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...
| |