Xcode with C++

FuryAshy

Registered
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
 
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.
 
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
 
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.
 
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.
 
Are you "using namespace std"? Otherwise try "std::cout" instead of simply "cout".
 
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> >::eek: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".
 
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.
 
Back
Top