我正在尝试编译我自己编写的 c++ 程序。而且我在编译它时遇到了麻烦。
quicksort.hpp文件是:
#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是:
#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;
}
但我收到这样的错误:
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
是否可以帮助我弄清楚为什么会出现此错误?
我正在使用 Debian Etch(Linux)、g++(gcc 版本 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)) 和 opencv 0.9.7-4