用C ++编写Sn Sn [英] Snipe hunting in C++

查看:102
本文介绍了用C ++编写Sn Sn的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了两个小时的大部分时间试图用我的

代码找到问题。错误消息实际上与实际的

问题无关。事实证明,问题是缺少}。在我从一个名称空间移动到另一个名称空间的文件中关闭一个

名称空间。第一次这样的事情发生时,这不是
。我想一段时间之后

我会更好地知道如何隔离这些问题。


这样的情况最糟糕的是我开始将代码更改为

看看它是否能解决问题。这可以引入其他问题,即在确定并纠正原始问题后,b $ b持续存在。其他

的人会遇到这样的情况吗?


对我而言,这是使用C ++的难点。我可以很好地理解语言的概念。我只是浪费了很多时间狩猎

狙击。

-

如果我们的假设是关于任何事情而不是关于某一个或更多

特定的东西,然后我们的推论构成数学。因此,数学可能被定义为我们永远不知道我们所讨论的是什么,以及我们所说的是否属实的主题。 - Bertrand

Russell

解决方案

Steven T. Hatton写道:

我花了两个小时的大部分时间试图找到我的
代码的问题。错误消息实际上与实际的问题无关。事实证明,问题是缺少}。关闭我从一个名称空间移动到另一个名称空间的文件中的名称空间。这不是第一次发生这样的事情。我想经过一段时间
我会更好地知道如何隔离这些问题。

这种情况最糟糕的是我开始将代码改为
看看它是否能解决问题。这可能会引发其他问题,这些问题在原始问题得到识别和纠正后仍然存在。其他人会遇到这种情况吗?

对我来说,这是使用C ++的难点。我能很好地理解语言的概念。我只是浪费了很多时间来寻找狙击手。




对于这个特定的问题,每当我打开{,我立即关闭它。

喜欢:


void function(){}


然后我开始填充身体。这确实有助于避免这样的错误。


Lieven写道:

对于这个特定问题,每当我打开一个{,我马上关闭它。
喜欢:

void function(){}

然后我开始填充身体。它确实有助于避免这样的错误。




我在创建命名空间或类时这样做。特别是当谈到

课程时,我发现最好确保在我做完之前把'';''放在

之前。在我上一篇文章中刚才描述的情况中,我是重构的,因此类和命名空间已经存在。我真的以为

当我换了东西时,我把''}'放在最后。也许我在保存文件之前无意中删除了它。

-

如果我们的假设是关于任何事情而不是关于某个或者更多

特定的东西,然后我们的推论构成数学。因此,数学可能被定义为我们永远不知道我们所讨论的是什么,以及我们所说的是否属实的主题。 - Bertrand

Russell





Lieven写道:
< blockquote class =post_quotes> Steven T. Hatton写道:

我花了两个小时的大部分时间试图找到我的
代码的问题。错误消息实际上与实际的问题无关。事实证明,问题是缺少}。关闭我从一个名称空间移动到另一个名称空间的文件中的名称空间。这不是第一次发生这样的事情。我想经过一段时间
我会更好地知道如何隔离这些问题。

这种情况最糟糕的是我开始将代码改为
看看它是否能解决问题。这可能会引发其他问题,这些问题在原始问题得到识别和纠正后仍然存在。其他人会遇到这种情况吗?

对我来说,这是使用C ++的难点。我能很好地理解语言的概念。我只是浪费了很多时间来寻找狙击手。



对于这个具体的问题,每当我打开一个{,我立即关闭它。
喜欢:

void function(){}

然后我开始填充身体。它真的有助于避免这样的错误。




他说他正处于代码维护的中间......并且它很容易*

在维护期间遇到这种情况。


David


I just spent the better part of two hours trying to find a problem with my
code. The error messages had virtually nothing to do with the actual
problem. The problem, as it turned out, was a missing "}" to close a
namespace in a file I had moved from one namespace to another. This isn''t
the first time something like this has happened. I guess after some time
I''ll get better at knowing how to isolate such problems.

The worst thing about situations like this is that I start changing code to
see if it will correct the problem. That can introduce other problems that
persist after the original problems is identified and corrected. Do other
people run into situations like this?

To me, this is the hard part about working with C++. I can understand the
concepts of the language fairly well. I just waste a lot of time hunting
snipes.
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell

解决方案

Steven T. Hatton wrote:

I just spent the better part of two hours trying to find a problem with my
code. The error messages had virtually nothing to do with the actual
problem. The problem, as it turned out, was a missing "}" to close a
namespace in a file I had moved from one namespace to another. This isn''t
the first time something like this has happened. I guess after some time
I''ll get better at knowing how to isolate such problems.

The worst thing about situations like this is that I start changing code
to
see if it will correct the problem. That can introduce other problems
that
persist after the original problems is identified and corrected. Do other
people run into situations like this?

To me, this is the hard part about working with C++. I can understand the
concepts of the language fairly well. I just waste a lot of time hunting
snipes.



For this specific problem, whenever I open a {, I immediately close it.
Like:

void function(){}

and then I start filling in the body. It really helps avoiding such errors.


Lieven wrote:

For this specific problem, whenever I open a {, I immediately close it.
Like:

void function(){}

and then I start filling in the body. It really helps avoiding such
errors.



I do that when I create a namespace or a class. Especially when it comes to
classes I find it best to be sure I put the '';'' at the end before I do
anything else. In the case I just described in my previous post, I was
refactoring, so the class and namespace already existed. I really thought
I had put the ''}'' at the end when I changed things. Perhaps I
inadvertently deleted it before I saved the file.
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell




Lieven wrote:

Steven T. Hatton wrote:

I just spent the better part of two hours trying to find a problem with my
code. The error messages had virtually nothing to do with the actual
problem. The problem, as it turned out, was a missing "}" to close a
namespace in a file I had moved from one namespace to another. This isn''t
the first time something like this has happened. I guess after some time
I''ll get better at knowing how to isolate such problems.

The worst thing about situations like this is that I start changing code
to
see if it will correct the problem. That can introduce other problems
that
persist after the original problems is identified and corrected. Do other
people run into situations like this?

To me, this is the hard part about working with C++. I can understand the
concepts of the language fairly well. I just waste a lot of time hunting
snipes.



For this specific problem, whenever I open a {, I immediately close it.
Like:

void function(){}

and then I start filling in the body. It really helps avoiding such errors.



he said he was in the middle of a code maintenance op tho... and it is *easy* to
get into such situations during maintanence.

David


这篇关于用C ++编写Sn Sn的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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