未解决的外部符号错误:-( [英] Unresolved external symbol error :-(

查看:82
本文介绍了未解决的外部符号错误:-(的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我只是想知道是否有人能用简单的语言解释这些错误是什么,以及它们为什么会出现。


更具体地说,如果你能解释为什么这段代码:

Hi,

I was just wondering if anyone could explain in simple terms what these errors are, and why they come about.

More specifically if you could explain why this code:

展开 | 选择 | Wrap | 行号

推荐答案

展开 | Se lect | Wrap | 行号


在.h文件中定义类时,只声明其成员。你需要在你的.cpp文件中定义它们;
;所以你必须在你的.cpp文件中定义静态int数组

,然后你就可以了。


亲切的问候,


Jos


ps。只有内联成员在clas定义中定义。
When you define your class in your .h file you only declare its members. You
have to define them in your .cpp file; so you have to define your static int array
in your .cpp file and you''re in business.

kind regards,

Jos

ps. only inline members are defined inside the clas definition.


感谢您的输入。我还是C ++和整个.h .cpp文件的新手以及何时使用它们。


所以在.h文件中我应该声明我班级所有可能的变量使用,私有和公共。


在类的.cpp中我应该实现我的所有功能吗?


.cpp文件可以吗访问.h中声明的私有数据成员呢?因为那是我的主要困惑。当我创建一个访问器方法时,我把它放在.h中,因为我一直以为.cpp无法访问私有成员。


上面的代码全部在二进制文件中.h文件和调用是在main.cpp中。 main.cpp不能被我触及,这是一个标准测试,所以我不能在其中声明内容或任何东西。我只是在尝试尝试看看我实现的掩码功能是否真的有效,到目前为止它不是:(
Thanks for your input. I''m still new to C++ andthe whole .h .cpp files and when to use which.

So in the .h file I should declare all the possible variable that my class will use, private and public.

In the .cpp of the class I should implement all of my functions?

Can the .cpp file access the private data members declared in the .h then? Because that is the main confusion I have. When I create an accessor method I put it in the .h because I always thought the .cpp was unable to access the private members.

With the code above it is all in the Binary.h file and the calling is in the main.cpp. The main.cpp cannot be touched by me, it is a standard test, so I can''t declare things within it or anything. I am just experimenting to try and see if the mask function I implemented is actually working, and so far it isn''t :(


这篇关于未解决的外部符号错误:-(的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆