함수가 없다고 합니다.
글쓴이: Geniys / 작성시간: 수, 2006/01/11 - 3:19오후
도대체 에러가 나는지를 모르겠습니다. ㅠ,ㅠ :oops:
#include <iomanip> #include <ios> #include <iostream> #include <string> #include <vector> #include <algorithm> #include <stdexcept> using std::cin; using std::cout; using std::endl; using std::setprecision; using std::string; using std::streamsize; using std::sort; using std::vector; istream& read_hw(istream& in, vector<double>& hw) { return in; } int main() { cout << "Please enter your first name: "; string name; cin >> name; cout << "Hello, " << name << "!" << endl; cout << "Please enter your midterm and final exam grades: "; double midterm, final; cin >> midterm >> final; vector<double> homework; read_hw(cin, homework); return 0; }
보기엔 간단한 코드인데 이상하게 함수 선언부분이 에러로 나오는 군요.
에러는 다음과 같습니다.
Quote:
tc.cpp:19: error: expected constructor, destructor, or type conversion before '&' token
tc.cpp:19: error: expected `,' or `;' before '&' token
tc.cpp: In function `int main()':
tc.cpp:39: error: `read_hw' undeclared (first use this function)
tc.cpp:39: error: (Each undeclared identifier is reported only once for each function it appears in.)
Forums:
[code:1]using std::istream ;
을 추가하세요.
표준라이브러리에 있는 모든 것은 std namespace 안에 있습니다.
그냥 using namespace std 하세요
그냥 using namespace std 하세요
생각을 못했던 부분이군요 ^^;그렇다면 또한 궁금한게 표준라이브러
생각을 못했던 부분이군요 ^^;
그렇다면 또한 궁금한게 표준라이브러리는 전부 std 안에 있다 하셨는데..
정확히 어떤것들이 std 영역에 속해있는지 알수 있는 방법이 있을까요?
============================
A watched pot never boils
C 에서 호환을 위한 라이브러리와 C++ 에서 추가된 표준라이브러리 들은
C 에서 호환을 위한 라이브러리와 C++ 에서 추가된 표준라이브러리 들은 모두
namespace std 에 들어있습니다.
C++ 에서 stdlib 을 쓰고자 한다면 두 가지 방법이 있을 수 있겠지요.
1. #include <stdlib.h>
2. #include <cstdlib>
이 때 1번에 들어있는 라이브러리는 std 안에 들어있지 않고
2번에 들어있는 라이브러리는 std 안에 들어있습니다.
[quote="Anonymous"]C 에서 호환을 위한 라이브러리와 C+
그렇지 않은 것들이 좀 있는데
- 매크로 : NULL, assert 등 (namespace의 적용 대상이 아님)
- operator new, operator delete (global namespace)
입니다.
그 이외의 이름은 모두 std 또는 std 안에 정의된 namespace에 들어 있습니다.
댓글 달기