# Xcode with C++



## FuryAshy (Jul 11, 2008)

Hi all i am new to C++ using xcode .... i add in new file helloword and it create .h and .cpp file ... bascially i type 

#include <iostream.h>
#include "helloworld.h"

using namespace std;

int main () 
{
cout << "hello world!!!";
return 0;
}

but it  gave me error message
#ifdef __DEPRECATED
#warning This file includes at least one deprecated or antiquated header. \
Please consider using one of the 32 headers found in section 17.4.1.2 of the \
C++ standard. Examples include substituting the <X> header for the <X.h> \
header for C++ includes, or <iostream> instead of the deprecated header \
<iostream.h>. To disable this warning use -Wno-deprecated.
#endif

can anyone tell me how to solve it thanks alot


----------



## Viro (Jul 11, 2008)

Change the line #include <iostream.h> to #include <iostream>.

I don't know what C++ book you're using, but the example code you've posted was outdated about 10 years ago.


----------



## FuryAshy (Jul 11, 2008)

oh thanks anyway.....  i am using xcode 3.0 anyway ... but i am very curious , i create a project , added in new file helloworld , it create helloworld.h and helloworld.cpp ...... is there any differences?? .... i only know .h is the header file .... need help thx


----------



## Viro (Jul 11, 2008)

When you create a file, if you don't want a .h file to be created, you need to untick the checkbox that creates the corresponding header file.


----------



## cocaine (Sep 28, 2010)

Hello there, I have same exact problem when I include iostream.h. 

I tried to include <iostream> only but it then doesn't recognize cout. I get following message: 
_cout was not declared in this scope_

Please help.


----------



## Mikuro (Sep 28, 2010)

Are you "using namespace std"? Otherwise try "std::cout" instead of simply "cout".


----------



## cocaine (Sep 28, 2010)

I get following message when I did "std::cout"

_"___gxx_personality_v0", referenced from:
      ___gxx_personality_v0$non_lazy_ptr in ccjmCcuD.o
  "std::ios_base::Init::~Init()", referenced from:
      ___tcf_0 in ccjmCcuD.o
  "std::ios_base::Init::Init()", referenced from:
      __static_initialization_and_destruction_0(int, int)in ccjmCcuD.o
  "std::basic_ostream<char, std::char_traits<char> >:perator<<(int)", referenced from:
      _main in ccjmCcuD.o
  "std::cout", referenced from:
      __ZSt4cout$non_lazy_ptr in ccjmCcuD.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
_

same with "using namespace std".


----------



## artov (Sep 30, 2010)

I tried the same program. When compiling with "CC" command, I got lots of linker errors, but with "g++ hello.cc -o hello" the program compiled and works.


----------

