어떻게 전역 함수의 헤더와 구현을 나눌 수 있습니까?글로벌 함수 헤더 및 구현
내 방법은 다음과 같습니다
split.h
#pragma once
#include <string>
#include <vector>
#include <functional>
#include <iostream>
void split(const string s, const string c);
split.cpp
#include "split.h"
void split(const string& s, const string& c){
...
}
MAIN.CPP
// main.cpp : Defines the entry point for the console application.
//
#include <string>
#include <vector>
#include <functional>
#include <iostream>
#include "stdafx.h"
#include "split.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
vector<string> v;
string s = "The;;woraaald;;is;;not;;enoaaaugh";
string c = " aaa ;; ccc";
split(s,c);
return 0;
}
그리고 오류는 다음과 같습니다
오류 1 오류 C4430 : 누락 된 형식 지정자 - int가 사용됩니다. 참고 : C++은 지원하지 않습니다 기본-INT ... \ 8
오류이 오류 C2146 split.h : 구문 오류 : 실종 ','식별자 '의'... \ split.h 8
전 이 문제를 어떻게 해결할 수 있습니까? 헤더 파일 사용 표준에서 들으
클래스 대 분할 정의
string const
에서또한 분할 선언 불일치 네임 스페이스'::은'표준에 있습니다. 헤더 파일에'using namespace'를 사용하지 말고 이름을 완전히 한정하십시오. 일관성을 위해, 아마 소스 파일에서 그 습관을 버리도록 노력하십시오. – GManNickG
두번째 에러는'std :: string'을 지정하지 않는 한'std :: string' 일 필요가있는'string'에 의해 발생합니다. –