g++ 로 컴파일을 하니...
vi 로 만든 hello.cpp인데요..
#include
int main()
{
cout << "Hello World!\n";
return 0;
}
컴파일을 하니...
밑에처럼 뜨길래...
[root@localhost c++]# g++ hello.cpp
In file included from /usr/include/c++/3.2.2/backward/iostream.h:31,
from hello.cpp:1:
/usr/include/c++/3.2.2/backward/backward_warning.h:32:2: warning: #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 header for the header for C++ includes, or instead of the deprecated header . To disable this warning
use -Wno-deprecated.
이렇게 뜨길래요...
게시판 검색하니 iostream.h 에서 .h 빼서 하라길래.
#include
int main()
{
cout << "Hello World!\n";
return 0;
}
이렇게 컴파일 하니..
[root@localhost c++]# g++ hello.cpp
hello.cpp: In function `int main()':
hello.cpp:5: `cout' undeclared (first use this function)
hello.cpp:5: (Each undeclared identifier is reported only once for each
function it appears in.)
이처럼 아예 컴파일이 안 되는데 해결 방법 없나요?
[code:1]#include <iostream>#incl
+++ 여기부터는 서명입니다. +++
국가 기구의 존속을 위한 최소한의 세금만을 내고, 전체 인민들이 균등한 삶을
영위할 수 있는 착취가 없는 혁명의 그날은 언제나 올 것인가!
-- 조정래, <태백산맥> 중에서, 1986년
적어준대로 했는데..
[root@localhost c++]# g++ hello.cpp
hello.cpp: In function `int main()':
hello.cpp:6: `cout' undeclared (first use this function)
hello.cpp:6: (Each undeclared identifier is reported only once for each
function it appears in.)
적어준 대로 작성했는데도 이렇게 나오는군요...
1%의 가능성이면 충분하다!
최선을 다하자!
음, 제가 보기엔 안 될 리가 없는데요? -_-;;'cat hel
음, 제가 보기엔 안 될 리가 없는데요? -_-;;
'cat hello.cpp'의 결과도 올려주시는게...
노루가 사냥꾼의 손에서 벗어나는 것 같이, 새가 그물치는 자의 손에서 벗어나는 것 같이 스스로 구원하라 -잠언 6:5
Re: 적어준대로 했는데..
전 잘 되는데...
이상하네요. 저 코드가 컴파일이 안되다니...
죄송합니다 ^^;; 초보라서..
잘 되네요...
using namespace std;
이걸 빼먹었습니다 ㅜ.ㅜ....
죄송..
그런데
#include<string>
using namespace std;
이 두줄 설명좀 해주세요.. 책에는 없으니깐 멀 뜻하는지 잘 모르겠어요..
1%의 가능성이면 충분하다!
최선을 다하자!
과거 string.h 나 iostream.h 가string 랑 ios
과거 string.h 나 iostream.h 가
string 랑 iostream 으로 .h 없는 형식으로 헤더파일명이 변했습니다.
그러니깐 .h 를 이용하는건 구식이고 신식을 그냥 .h 없는 걸 include 해서
코딩하는거져
파일명을 변경한건 과거의 헤더파일과 구별을 명시적으로 하기 위함인것 같은데
서로의 차이점은
iostream.h 은 cout 을 그냥 사용하면 되는거고
iostream 은 std::cout 하는 식으로 std:: 라는 걸 넣어 주어야 합니다.
좀 더 원론적으로 말하면
"최근 C++ 표준 라이브러리는 모두 std 라는 네임스페이스 내에 두는걸 원칙한다."
라고 할 수 있져
네임스페이스(namespace) 라는건 일종의 묶음 같은건데요
이건 별도로 찾아보시면 using namespace std; 라는게
뭘 의미하는지도 아실 수 있을 겁니다.
책에 namespace 라는게 없다면 다른 좋은 자료 많으니깐 인터넷에서 찾아보세요.
참고 : http://cplusplus.com/doc/tutorial/tut5-2.html
std::cout 이 뭘 의미하는지 이해하실려면 우선 namespace 에 대해 공부하시면 알게 되는 내용입니다.
책에 그런 내용이 없다면그 책은 버리시고딴 책 보세요...
책에 그런 내용이 없다면
그 책은 버리시고
딴 책 보세요...
iostream.h를 쓰고 using namespace std를 안 쓰는
iostream.h를 쓰고 using namespace std를 안 쓰는 책이라면 맹고이님의 말대로 버려도 무방합니다. c언어 책이라면 flush(stdin)이 있다면 버려도 되구요.
그리고 이상하게 안 쓰시는 분들도 많은데 c++에서는 c 해더들도 래핑해서 std 안에 두고 있습니다. stdio.h 해더는 cstdio 이런 식으로 .h를 때고 앞에 c를 붙여두고 있지요.
- 죠커's blog / HanIRC:#CN
[quote="CN"]c언어 책이라면 flush(stdin)이 있다면 버
여기에는 무슨 문제가 있는지 알려주시면 고맙겠습니다. (__)
----
It is essential, if man is not to be compelled to have recourse, as a last resort, to rebellion against tyranny and oppression, that human rights should be protected by the rule of law.
[Universal Declaration of Human Rights]
http://bbs.kldp.org/viewtopic.php?t=2592
http://bbs.kldp.org/viewtopic.php?t=25929
[quote="vacancy"]http://bbs.kldp.org/vie
아... 표준에 정의되지 않은 것이군요. :oops:
감사합니다.
----
It is essential, if man is not to be compelled to have recourse, as a last resort, to rebellion against tyranny and oppression, that human rights should be protected by the rule of law.
[Universal Declaration of Human Rights]
댓글 달기