gpt4 book ai didi

c++ - 这个 C++ 代码有什么问题?

转载 作者:太空宇宙 更新时间:2023-11-04 14:35:07 24 4
gpt4 key购买 nike

<分区>

我是初学者,我有一个问题:

此代码无法编译:

主要.cpp:

#include <stdlib.h>
#include "readdir.h"
#include "mysql.h"
#include "readimage.h"


int main(int argc, char** argv) {
if (argc>1){
readdir(argv[1]);
// test();
return (EXIT_SUCCESS);
}
std::cout << "Bitte Pfad angeben !" << std::endl ;
return (EXIT_FAILURE);
}

读取图像.cpp

#include <Magick++.h>
#include <iostream>
#include <vector>

using namespace Magick; using namespace std;

void readImage(std::vector<string> &filenames) {
for (unsigned int i = 0; i < filenames.size(); ++i) {
try {
Image img("binary/" + filenames.at(i));

for (unsigned int y = 1; y < img.rows(); y++) {
for (unsigned int x = 1; x < img.columns(); x++) {
ColorRGB rgb(img.pixelColor(x, y));
// cout << "x: " << x << " y: " << y << " : " << rgb.red() << endl;
}
}
cout << "done " << i << endl;
} catch (Magick::Exception & error) {
cerr << "Caught Magick++ exception: " << error.what() << endl;
}
} }

读取图像.h

#ifndef _READIMAGE_H
#define _READIMAGE_H

#include <Magick++.h>
#include <iostream>
#include <vector>
#include <string>

using namespace Magick;
using namespace std;

void readImage(vector<string> &filenames)


#endif /* _READIMAGE_H */

如果想用这段代码编译它:

g++ main.cpp Magick++-config --cflags
--cppflags --ldflags --libs
readimage.cpp

我收到此错误消息:

main.cpp:5: error: expected initializer before ‘int’

我不知道,为什么? :(

有人可以帮助我吗? :)

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com