C++ 这个C+有什么问题+;密码?

C++ 这个C+有什么问题+;密码?,c++,C++,我是初学者,我有一个问题: 此代码不编译: main.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); }

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

此代码不编译:

main.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);
}
#包括
#包括“readdir.h”
#包括“mysql.h”
#包括“readimage.h”
int main(int argc,字符**argv){
如果(argc>1){
readdir(argv[1]);
//test();
返回(退出成功);
}

std::cout在readimage.h中,在函数声明后缺少分号。

在readimage.h中,在readimage函数原型后缺少分号。

此函数声明:

void readImage(vector<string> &filenames)

是非法的。用下划线和大写字母开头的名字在C++中保留-你不允许自己创建这些名字。< /P> 在你的循环中:

for (unsigned int y = 1; y < img.rows(); y++) {
for(unsigned int y=1;y

您确定应该从1开始循环,而不是从零开始循环吗?

readimage.h

因为,
main.cpp
是先预处理的,所以它在
readimage.h
的最后一行找到错误,并在
main.cpp
中显示在
int
之前发生的错误


main.cpp:5:错误:在'int'之前应该有初始值设定项。
第一次编译时,首先要做的一件事是一次尝试一段代码。不要把一堆代码放在一起,希望它能编译。相反,一次只使用一段代码。因此,在这里,您可以注释掉include和您希望使用这些文件中的内容的代码

乍一看,它看起来像

void readImage(vector<string> &filenames)
void readImage(向量和文件名)

因为您正在声明它,所以在行尾缺少一个分号。

您只需要在readImage中的
readImage
声明的末尾添加一个分号即可。h:

void readImage(vector<string> &filenames);
void readImage(向量和文件名);

awww老兄……怎么会是主要错误D@mr.bio:事实上,错误发生在#include之后;这表明错误出现在您要包含的文件的末尾。我承认这在我身上发生过很多次。因为readimage.h是最后一个包含在main.cpp中的文件。
#include…
是一个straight文本替换。
#include
-ed文件中的错误会影响
#include
-ed文件的编译…错误在main中,因为#include实际上用作文本粘贴。因此,当编译器构建main.cpp时,它会将include中的所有代码视为一大块代码,而不是单独的文件。自上次readimage.h中的行本身是不完整的,然后它继续查看main.cpp(空白不会影响编译器。因此,该行最终看起来像“void readimage(vector&filenames)int main(int argc,char**argv){”,它不会编译。它只是在两个文件之间分割,所以很难看到.Tnaks。现在我明白了重点:)IncludeGuard由自动生成Netbeans@mr.bio真的吗?然后netbeans就坏了。但我怀疑这只是一些需要修复的文本模板,谢谢..循环建议..修复;)无关:从来没有在头文件中使用过
名称空间

for (unsigned int y = 1; y < img.rows(); y++) {
void readImage(vector<string> &filenames)
void readImage(vector<string> &filenames);