Jump to content
Compatible Support Forums

Garfield

Members
  • Content count

    2
  • Joined

  • Last visited

    Never

Community Reputation

0 Neutral

About Garfield

  • Rank
    stranger
  1. Garfield

    c++ question

    Most compilers still accept the old style ".h" header files for backwards compatibility. These old header files did not use namespaces, so they do not need the "std::" qualifier to be recognized by the compiler. The newer headers in the C++ standard do require this. Most books nowadays should use the newer header files. Those that don't should be, since many things have changed between the pre/post standards of C++.
  2. Garfield

    c++ question

    I see several problems: 1. <iostream.h> is not part of standard C++. The 1998 C++ standard uses <iostream> (no ".h") 2. Both <iostream> and <string> are in the "std" namespace. To use anything in the standard namespace, you need to append "std::" before the function you are using (example std::cout instead of just cout) Try: Code: #include <iostream>#include <string>int main (){ std::string mystring; mystring = "Hello There!"; std::cout << mystring << std::endl; return 0;} Also, int main() is correct. According to the c++ standard main returns an integer. If you omit the "return 0" statement, the compiler will add it for you. I'd suggest getting a couple of good c++ books. "Accelerated c++" is a good one to start with. Try www.accu.org for book reviews. Hope this helps, Scott
×