[英]C++ expected a type specifier for class object
我試圖用頭文件創建一個類對象,但是我在主函數中不斷收到此錯誤。
這是頭文件:
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
using namespace cv;
class helper {
public:
helper();
~helper();
void setLabel(cv::Mat& im, const std::string label, const cv::Point & or , const cv::Scalar col);
};
這是cpp文件:
#include "helper.h"
helper::helper() {
}
void helper::setLabel(cv::Mat& im, const std::string label, const cv::Point & or , const cv::Scalar col)
{
int fontface = cv::FONT_HERSHEY_SIMPLEX;
double fontScale = 0.4;
int thickness = 1;
int baseline = 0;
cv::Size text = cv::getTextSize(label, fontface, fontScale, thickness, &baseline);
cv::putText(im, label, or , fontface, fontScale, col, thickness, CV_AA);
}
現在在main.cpp中,當我嘗試創建實例時:
#include "helper.h"
int main(){
helper* helper = new helper;
}
它顯示此錯誤:
C2061語法錯誤:標識符'helper'
如何在main中定義此類的實例? 我在Windows x64上使用Visual Studio 2015。
為變量使用其他名稱。
helper* obj = new helper;
當您使用變量名與類名相同時,類名會被變量名遮蓋。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.