如何初始化和使用静态结构 [英] how to initialize and use static struct

查看:47
本文介绍了如何初始化和使用静态结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个类中定义了一个静态结构.但它导致错误为 Error

I have defined a static struct in a class. but it is resulting error as Error

错误 LNK1120:1 个未解析的外部

error LNK1120: 1 unresolved externals

我的头文件

class CornerCapturer{
    static struct configValues
    {
        int block;
        int k_size;
        int thre;
        double k;
        configValues() :block(2), k_size(3), thre(200), k(0.04){}
    }configuration;
public:
    void captureCorners(Mat frame);
}

我的 cpp 文件

void CornerCapturer::captureCorners(Mat frame){

    int y= CornerCapturer::configuration.thre;
}

请帮帮我

推荐答案

将此添加到您的 cpp 文件中;实例化静态结构:

Add this into your cpp file; to instantiate the static structure:

CornerCapturer::configValues CornerCapturer::configuration;

并且不要忘记 ; 在您的类的封闭 } 之后.

and dont forget the ; after the enclosing } of your class.

这篇关于如何初始化和使用静态结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆