2

これはおそらく単純なことですが、私には理解できません。

私のmain.cppには次のものがあります:

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

そして、私の ImageProcessor.h には次のものがあります。

//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 には

int* dailyPrices(const Image& abp_chart)
{

しかし、コンパイルしようとすると、main.cpp に次のエラーが表示されます。

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

3 に答える 3

5

関数を定義するときにクラス名がありませんdailyPrices:

int* ImageProcessor::dailyPrices(const Image& abp_chart)
//   ______________^ 
{
    // 
}
于 2013-07-02T14:21:02.843 に答える
0

ImageProcessor::メソッド定義に追加する必要があります。

int* ImageProcessor::dailyPrices(const Image& abp_chart)
     ^^^^^^^^^^^^^^^^
于 2013-07-02T14:21:09.927 に答える
0

DailyPrices は ImageProcessor 名前空間にある必要があります。

int* ImageProcessor::dailyPrices(const Image& abp_chart)
于 2013-07-02T14:21:23.970 に答える