직접 작성한 C++ 프로그램을 컴파일하려고합니다. 그리고 컴파일하는데 문제가 있습니다.C++ 컴파일 오류 : '<'토큰 앞에 예상 초기화 자
quicksort.hpp 파일은 다음과 같습니다
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include "cv.h"
#include "highgui.h"
#include "quicksort.hpp"
int main()
{
vector<CvPoint3D32f> input;
for(int r = 0; r <= 9;r++)
{
input.push_back(cvPoint3D32f(2.0f+r,2.1f+r,3.1f+r));
}
std::cout << "Input: ";
print(input);
return 0;
}
하지만이 같은 오류를 받고 있어요 :
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include "cv.h"
#include "cv.hpp"
#include "highgui.h"
void print<CvPoint3D32f>(vector<CvPoint3D32f>& input)
{
for (int i = 0; i < input.size(); i++)
{
std::cout << input[i].y << " ";
}
std::cout << std::endl;
}
그리고 Test.cpp에가
quicksort.hpp:4: error: expected initializer before ‘<’ token
test.cpp: In function ‘int main()’:
test.cpp:22: error: ‘print’ was not declared in this scope
test.cpp:22: error: expected primary-expression before ‘>’ token
친절하게도 알아낼 수 있습니까? 왜이 오류가 발생합니까?
내가 데비안 엣지 (리눅스), g ++ (GCC의 4.1.2 20061115 (시험판 버전) (데비안 4.1.1-21)) 및 OpenCV의를 사용하고 0.9.7-4
'print '가 올바르지 않습니다. 'template' 헤더는 어디에 있습니까? –
iammilind
'print'을'print'로 바꾼다 –
sashang
'vector'는'std :: vector'이어야한다. – Naveen