继承时找不到类名

Class name not found when inheriting

本文关键字:找不到 继承      更新时间:2023-10-16

我在从类继承时遇到问题,在互联网上查找错误被认为是循环包含,但我没有看到我在代码中是如何做到这一点的。

错误如下:

./src/Camera.hpp:6:40: error: expected class-name before ‘{’ token
 class Camera : public cv::VideoCapture {

我从中继承的类是OpenCV的一部分。以下是代码的相关部分:

main.cpp:

#include <opencv2/core.hpp>
#include "Camera.hpp"
int main(int argc, char** argv){
    Camera camera = Camera(/*Some parameters*/);
    return 0;
}

Camera.hpp

#ifndef CAMERA_H
#define CAMERA_H
#include <opencv2/core.hpp>
class Camera : public cv::VideoCapture {
    public:
    Camera(/*Some parameters*/);
};
#endif

main.cpp中还包含一些其他文件,但我确保(为了测试)它们都没有使用Camera.hpp。我做错了什么?

感谢

如果它不知道VideoCapture是一个类,那么可能您没有包含正确的头文件。

http://docs.opencv.org/java/2.4.8/org/opencv/highgui/VideoCapture.html提示CCD_ 2。