0

我正在尝试编译我自己编写的 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 ‘&lt;’ 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 ‘&gt;’ token

是否可以帮助我弄清楚为什么会出现此错误?

我正在使用 Debian Etch(Linux)、g++(gcc 版本 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)) 和 opencv 0.9.7-4

4

1 回答 1

1

说啊:

void print(vector<CvPoint3D32f>& points){

这将解决问题。如果不是,您需要声明一个模板,如果真的有必要,请查看您的 CvPoint3D32f 的模板专业化,但这将是矫枉过正。

于 2012-05-17T04:16:57.977 回答