[Techtalk] simple reference book on C++/ was [Techtalk] sim
Kathryn Hogg
kjh at flyballdogs.com
Thu Jan 31 16:01:06 EST 2002
One thing you need to be careful of is whether your compiler/environment is
using pre-ISO C++ commonly called ARM C++. ARM stands for "Annotated
Reference Manual" by Bjarne Stroustrap which served as the language
reference for many years.
One of the major changes in arm vs iso c++ is the iostreams library. For
example, in the arm world you would have
include <iostream.h>
int main(int, char **)
{
cout << "hello world!" << endl
return 0;
}
and with std iostreams, you have
include <iostream>
us#if __cplusplus >= 199707Ling std::cout;
int main(int, char **)
{
cout << "hello world!" << endl
return 0;
}
Since we are linuxchix, I'm assuming that you are compiling with gcc. What
version do you have?
$ gcc --version
3.0.3
gcc has been catching up to the iso standard and 3.0.2 and up do a pretty
good job and support the standard iostreams. You woukd compile the above
program (assuming it is in hello.C) as
$ g++ -o hello hello.C
if you aren't sure if your compiler is std c++ compliant, tweak the code a
little:
#if __cplusplus >= 199707L
#define HAS_STD_CXX 1
#else
#define HAS_STD_CXX 0
#endif
#if HAS_STD_CXX
#include <iostream>
using std::cxx;
#else
#include <iostream.h>
#endif
int main(int, char **)
{
cout << "hello world" << endl;
return 0;
}
--
Kathryn
More information about the Techtalk
mailing list