未定义的静态方法引用 [英] Undefined reference to static method

查看:139
本文介绍了未定义的静态方法引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是简单的,但我不能弄清楚。

This is probably something simple but I can't figure it out.

在我的main.cpp我有:

In my main.cpp I have:

Image image("/path/to/image.png");
int* h = ImageProcessor::dailyPrices(image);

在我的ImageProcessor.h中,我有:

And in my ImageProcessor.h I have:

//Maybe something is wrong with this? I am trying to forward declare.
namespace Magick
{
class Image;
}

class ImageProcessor {
public:
ImageProcessor();
virtual ~ImageProcessor();
static int* dailyPrices(const Magick::Image& abp_chart);
};

在ImageProcessor.cpp中有

And in ImageProcessor.cpp I have

int* dailyPrices(const Image& abp_chart)
{

但是在尝试编译时,我在main.cpp中收到以下错误:

But upon attempt to compile I receive the following error in my main.cpp:

path/to/VendBot.cpp:17: undefined reference to `ImageProcessor::dailyPrices(Magick::Image const&)'


推荐答案

定义 dailyPrices 函数时缺少类名:

int* ImageProcessor::dailyPrices(const Image& abp_chart)
//   ______________^ 
{
    // 
}

这篇关于未定义的静态方法引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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