From: Alf P. Steinbach on
* jg.campbell.ng(a)gmail.com:
> * Alf P. Steinbach:
>>
>> Btw., the program technically needs to include <ostream>.
>
> Why?

Because <iostream> only is guaranteed to declare the eight standard
stream objects. The operator<< used in the code is as far as I recall
not a member function, and std::endl is not guaranteed to be available.
Those are supplied by <ostream>.

With at least one compiler that code will fail to compile.

On the other hand, presumably this will be fixed in C++0x, since nearly
all the non-normative examples in the standard do the same thing (but on
the third and gripping hand, the non-normative examples are not exactly
free of errors, such as the 1998 standard's examples of sequence points,
corrected, IIRC, in TC1 aka C++2003, and the committee is overworked).

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
From: Richard Heathfield on
jg.campbell.ng(a)gmail.com said:

> These students are learning DirectX as well, so
> I cannot be bothered even introducing them to Cygwin or MinGW.

Understood. Never fear... the keen ones will work it out for themselves.

>
> [...]
>> Oh, just one more thing:
>>
>> > //c.val_= 345; // remove the first "//" and see if the program
>> > compiles
>>
>> ...which is that when I tested this program on gcc, the two lines quoted
>> above gave me a syntax error. On Usenet, /* comments */ are far better,
>> as they survive line-wrapping. (After I fixed this, the program compiled
>> just fine, and gave the expected runtime results.)
>
> Runtime? Surely compile time?

No, I left the comment in-place. Never fear - I know what would happen if I
were to remove it! :-)

> Thanks everyone. I'm going to think no more of it. They were told to
> use VS Express, so I owe him no duty of support;

Hahaha! :-) That's lovely - "you were told to use this cheap tacky free
thing, and you used that shiny expensive thing instead, so that's your
problem, not ours". And the crazy thing is, you're right. (This is not a
criticism of you. I just can't resist the ironic flavour that always seems
to creep into discussions of Microsoft software...)

> God knows what mixture of include files he has --- the problems occur
> only on the student's personal laptop.

This is beginning to sound more and more like a hacked-up hack job, isn't
it? Frankly, I'd just make him ditch the thing and use what you told him to
use in the first place.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
From: Jim Langston on
<jg.campbell.ng(a)gmail.com> wrote in message
news:1164802543.098792.231930(a)16g2000cwy.googlegroups.com...
> When compiling the program below using Visual Studio 2005 Professional,
> one of my students gets the error messages:
>
> Error 1 error C2039: 'exit' : is not a member of '`global
> namespace'' c:\program files\microsoft visual studio
> 8\vc\include\cstdlib 23
>
> Error 2 error C2873: 'exit' : symbol cannot be used in a
> using-declaration c:\program files\microsoft visual studio
> 8\vc\include\cstdlib 23
>
> The errors occur also on other apparently correct programs.
>
> A Microsoft website says something about enclosing #include <csdtlib>
> in namespace std. That doesn't make any sense to me.
>
> Another student has compiled the program successfully on VS 2005 Prof.
> The remainder of the class are using VS Express, and that is okay too.
>
> I suspect that there may be problems with his installation of VS 2005
> Prof. But I'm mildly curious; anyone any suggestions?
>
> ----------------------------
> #include <iostream>
> using namespace std;
>
> class Cell{
> public:
> Cell(){val_= 0;}
> void set(int val){val_= val;}
> int get(){return val_;}
> void print(){cout<<"value= " << val_<< endl;}
> private:
> int val_;
> };
>
> int main()
> {
> Cell c;
> c.set(123);
> cout<< "Cell c: "<< endl; c.print();
>
> Cell* pc= &c;
> cout<< "Cell* pc = &c: "<< endl; pc->print();
>
> //c.val_= 345; // remove the first "//" and see if the program
> compiles
> return 0;
> }
> -------------------------------------
>
> Best regards,
>
> Jon C.

This may have nothing to do with it, but today I couldn't compile a program
with a simple
#include <winsock2.h>
int main() { return 0; }

Got an error in WinNT.h.

Turned out I had turned off Language Extentions in the project, and
apparently WinNT.h used them.

So you might want to check that Langauge Extentions are turned on (although
they proably are, on by default when creating a project)