C++代码块IDE错误?

发布于 2024-12-22 00:28:10 字数 383 浏览 4 评论 0原文

我在硬盘上安装了代码块,编译器工作正常。它在高清上的原因是因为我的学校不喜欢人们在计算机上安装东西......

main.cpp 工作正常。如果我将所有内容都编码进去,我就不会遇到任何问题。唯一的问题是,如果我向项目添加一个类,我会收到几个错误。

在此处输入图像描述

我接触过这些类,它们在我家里的计算机上编译得很好。是否是因为项目没有保存在正确的目录/文件夹中?我在硬盘上的 codeblocks 文件夹中有一个项目文件夹,因此它应该能够找到 theclass.h 和 theclass.cpp 文件。

如果 main.cpp 也不起作用,那就更有意义了。但为什么新的类不起作用呢?

I have codeblocks installed on an HD, the compiler works fine. The reason its on an HD is because my school doesn't like people installing things onto the computers...

main.cpp works fine. If I coded everything in this I wouldn't run into any problems. The only problem is, if I add a class to the project I get several errors.

enter image description here

I touched the classes at all, they compile fine on my computer at home. Is it because the project is not saved in a proper directory/folder? I have a folder for the project inside the codeblocks folder on the HD, so it should be able to find the theclass.h and theclass.cpp files.

If main.cpp also didn't work, it would make more sense. But why is it that the new class won't work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

时光暖心i 2024-12-29 00:28:10

看起来 theclass.h 位于 include 目录中,该目录是 src 的同级目录。您应该将这两个文件放在同一目录中,或者如果您绝对必须将文件保留在原处,则应使用#include "../theclass.h"

It looks like theclass.h is in the include directory, a sibling directory of src. You should either get both files in the same directory, or use #include "../theclass.h" if you absolutely must keep the files where they are.

云之铃。 2024-12-29 00:28:10

是的,实际上 codeblocks 有这个错误,你要做的就是从文件夹中获取类,即 .cpp 和 .h 并将它们放入项目的根目录中,因此剪切它们并将它们粘贴到 main.cpp 所在的位置应该也可以工作,你可以做的就是放置#include“source/theclass.cpp”,你也可以这样解决它(也对.h做同样的事情)

yeah actually codeblocks has this error what you have to do is get the classes namely the .cpp and the .h out of the folder and get them in the root of the project so cut them and paste them where the main.cpp is and it should work also what you can do is put #include "source/theclass.cpp" and u can also solve it that way(also do the same for the .h

〃安静 2024-12-29 00:28:10

Codeblocks 将文件移动到单独的包含目录和源目录。这就是#include "theclass.h" 导致错误的原因。

Codeblocks moves the files to seperate include and source directories. This is why #include "theclass.h" leads to an error.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文