C++代码块IDE错误?
我在硬盘上安装了代码块,编译器工作正常。它在高清上的原因是因为我的学校不喜欢人们在计算机上安装东西......
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.
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看起来
theclass.h
位于include
目录中,该目录是src
的同级目录。您应该将这两个文件放在同一目录中,或者如果您绝对必须将文件保留在原处,则应使用#include "../theclass.h"
。It looks like
theclass.h
is in theinclude
directory, a sibling directory ofsrc
. 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.是的,实际上 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
Codeblocks 将文件移动到单独的包含目录和源目录。这就是
#include "theclass.h"
导致错误的原因。Codeblocks moves the files to seperate include and source directories. This is why
#include "theclass.h"
leads to an error.