From: Giovanni Dicanio on
"RB" <NoMail(a)NoSpam> wrote:

Just a couple notes:

> I put the
> #include <vector>
> #include <iostream>

I would suggest to put these #include's in "StdAfx.h" (precompiled headers).

> using namespace std;

In a real-world project, instead of 'using namespace std', I would just use
std::vector.
I think importing the whole std:: namespace is OK in simple test code, but
not in real-world apps.

HTH,
Giovanni


From: RB on
Hey Joe, actually I did post the error msgs along with the
corresponding code but it was a few threads back up.
I did not post the entire class if that is what you mean.
In any case what was confusing me was that I had
no errors until I posted the vector samples and then
I would. But as previously posted I have rectified that
and have started to increment the application now in
a new project.
Thanks always for all the help you give me even though
I may not post conducively always.




From: RB on


>In a real-world project, instead of 'using namespace std', I would just use std::vector. I think importing the whole std::
>namespace is OK in simple test code, but not in real-world apps.

Thanks and if you would comment further on these:
I have read that putting
using namespace std
in the include file "bloats" the application. But putting it in a cpp file
only affects that cpp file of the app.
What exactly does this mean. I have never really gotten under the
namespace thing but I thought it was something similar in concept
to a define.

Also I have always wondered when you include an include file,
it only adds "referenced" items to app from the includes, correct?
In other words it doesn't add the entire include code to your app,
correct ?


From: Joseph M. Newcomer on
You did not indicate that the error messages you reported were the SAME error messages as
cited in the previous message; you left us with the impression that these were a new set
of errors.
joe

On Sun, 9 May 2010 08:43:18 -0400, "RB" <NoMail(a)NoSpam> wrote:

>Hey Joe, actually I did post the error msgs along with the
>corresponding code but it was a few threads back up.
>I did not post the entire class if that is what you mean.
> In any case what was confusing me was that I had
>no errors until I posted the vector samples and then
>I would. But as previously posted I have rectified that
>and have started to increment the application now in
>a new project.
>Thanks always for all the help you give me even though
>I may not post conducively always.
>
>
>
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Joseph M. Newcomer on
See below...
On Sun, 9 May 2010 08:52:01 -0400, "RB" <NoMail(a)NoSpam> wrote:

>
>
>>In a real-world project, instead of 'using namespace std', I would just use std::vector. I think importing the whole std::
>>namespace is OK in simple test code, but not in real-world apps.
>
>Thanks and if you would comment further on these:
>I have read that putting
>using namespace std
>in the include file "bloats" the application.
****
I fail to see how qualifying a namespace can "bloat" an application. I am not sure what
you read that suggests this, but a namespace is merely syntactic directive to the
compiler, and generates no code.
****
>But putting it in a cpp file
>only affects that cpp file of the app.
>What exactly does this mean.
***
As I said, I have no idea what this could possibly mean, since the notion of a syntactic
directive "bloating" an application seems inherently nonsensical.
****
>I have never really gotten under the
>namespace thing but I thought it was something similar in concept
>to a define.
****
No, it is a directive to C++ that tells it that when it has an unqualified name, it first
checks local scope, then class scope, then the selected namespaces, then the global
namespace. I'm not sure if there is a defined order to the namespace searches, or it is
left up to the compiler writer to determine the order, and I don't want to look it up
right now. But "bloat" is one of those nonsensical terms (like "crash") that seems to
have meaning but is largely nonsensical (for example: if you have code that is actually
callable, and does something, it is not "bloat", it is "part of the functionality of the
program". An unholy fascination with code size is the mark of a beginner ("What's wrong
with Windows? I did "hello world" and got <explanation of meaningless numbers follows>
but in Unix it is only <equally meaningless comparison of meaningless numbers>" as if .exe
file size, process address space size, or any other meaningless metric had relevance for
modern programming. But attributing "using namespace" to causing "bloat" sounds to me
like total nonsense.
****
>
>Also I have always wondered when you include an include file,
>it only adds "referenced" items to app from the includes, correct?
>In other words it doesn't add the entire include code to your app,
>correct ?
****
No, it substitutes the text of the included file, period. It is as if you had replaced
the #include with a copy-and-paste of the contents of the file. Nothing more, and nothing
less. If you have a header file that includes a million bytes of code, every compilation
gets a million bytes of code. But that would just be poor programming.

Note that the LINKER can drop subroutines that are not called, but this is not the role of
the compiler.

Note that 'using namespace' does NOT generate any code, so claiming it can "bloat" an
application is nonsense. And it does not make the runtime symbol table any larger,
because the runtime symbol table is going to be the same size whether you declare a 'using
namespace' or not. All the 'using namespace' declaration changes is the rules for how
that symbol table is searched!

Personally, I find 'using namespace std' to be an excuse for lazy programmers to not type
std:: ahead of what should be qualified names. I always type std:: in front of any
component of the std:: namespace; it is a better form of documentation, does not result in
ambiguities, and overall makes it more obvious to future maintainers what is going on. But
it cannot make your app bigger by using it.
joe
****
>
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm