简体   繁体   English

无法使用代码块编译C ++类

[英]Unable to compile a C++ class using code blocks

Everytime I try to compile a class in c++ I get this error: 每次我尝试用c ++编译一个类时我都会遇到这个错误:

||=== Build file: "no target" in "no project" (compiler: unknown) ===| || ===构建文件:“无项目”中的“无目标”(编译器:未知)=== |

Here is the code for my Classes class: 这是我的Classes类的代码:

#include <iostream>
#include "Cat.h"
using namespace std;

int main() {
    Cat cat1;
    cat1.speak();
    cat1.jump();

    return 0;
}

Here is the code for my header Cat.h: 这是我的标题Cat.h的代码:

#ifndef CAT_H_
#define CAT_H_

class Cat {
public:
    void speak();
    void jump();
};

#endif /* CAT_H_ */

And here is the code for my Cat Class: 以下是我的Cat类的代码:

#include <iostream>
#include "Cat.h"
using namespace std;

void Cat::speak() {
     cout << "Meouwww!!!" << endl;
}

void Cat::jump() {
    cout << "Jumping to top of bookcase" << endl;
}

This error have nothing to do with your code. 此错误与您的代码无关。 It's a problem related to your environnement. 这是与您的环境相关的问题。 There is 2 commun mistake that will lead to this: 有两个共同的错误导致这个:

There is no compiler associated with your IDE so try to install one. 没有与IDE关联的编译器,因此请尝试安装一个。 Or you should Download codeBlocks with mingw compiler integrated 或者您应该使用集成的mingw编译器下载codeBlocks

You didn't create a project So try creating a project and then add this files. 您没有创建项目因此尝试创建项目然后添加此文件。

I hope that I answered your question. 我希望我回答你的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM