头文件真的有用吗? [英] Do header files really serve a useful purpose?

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

问题描述

我在计算机行业工作了几年后正在学习C ++

同时进行系统管理和工程。我已经编写了代码

Perl,Bash,Pascal,Ada,C,Mathematica(数百行OO代码,而不是
1 + 1),JavaScript, Lisp,Java,以及C ++。这些语言中的每一种都有它的优点和缺点。我使用C ++的经历告诉我

这是我学习中最困难的。


我有一些感觉C ++是不必要的,而且
服务器没什么用处。尽管如此,它们确实增加了学习语言的复杂性,从而增加了学习语言的难度。我知道

有很多用这种语言编写的优秀软件。

也许我没有准确地感知事物,但我感觉C ++

正在失去其他语言的重要地位,特别是Java。


我不太确定为什么我有动力去学习这门课程,但我有a

真正希望确定C ++的哪一部分可以从语言的整个部分中提取出来,并以某种方式进行修改,并仍然提供

几乎所有当前语言的功能。无视

Stroustrup对莎士比亚的解释,我相信这可能是一项很好的运动,而b
基本上是将这种语言用于审判。也许这样的事情已经完成了。我正在谈论一个sicere批评,而不是一个情绪化的攻击。<​​br />

所以从这个意义上说,我会问什么是好的头文件。他们似乎只是对我来说是行政开销。我相信他们鼓励

程序员避免将他们的工作分成适当的自包含对象。这似乎也鼓励程序员避免使用名称空间。


对我而言,当他们试图记住

所有的规则时,他们只是另一个混​​乱点。声明和定义编程结构。据我所知,这些

规则并不是一个紧凑的,可访问的参考资料。

我发现自己翻了几章试图找到答案

有关参数分配的具体问题默认为可选的

参数等。


所以,现在我已经说了很多坏事关于这门语言的事情,让我来说,b $ b提到我真正喜欢的东西,虽然它们对我来说还是新手。函数

很酷!


STH

I''m learning C++ after having spent several years in the computer industry
doing both system administration and engineering. I''ve written code in
Perl, Bash, Pascal, Ada, C, Mathematica (hundreds of lines of OO code, not
1+1), JavaScript, Lisp, and Java, as well as C++. Each of these languages
has it''s strengths and weaknesses. My experience with C++ has shown me
that it is by far the most difficult for me to learn.

I have the sense that some of the features in C++ are unnecessary, and
server little real purpose. None the less, they do serve to add to the
complexity, and hence the difficulty, of learning the language. I know
there is a good deal of excellent software written in the language.
Perhaps I''m not perceiving things accurately, but I have the sense that C++
is losing significant ground to other languages, expecially Java.

I''m not really sure why I''m motivated to follow this course, but I have a
real desire to determine what part of C++ could be extracted from the
entire body of the language, modified in certain ways, and still provide
virtually all the capabilities of the current language. Disregarding
Stroustrup''s paraphrase of Shakespeare, I believe it might be fine sport to
basically put the language on trial. Perhaps such a thing has already been
done. I''m talking about a sicere critique, not an emotional attack.

So in that sense, I will ask what good header files really are. They seem
to be nothing but administrative overhead to me. I believe they encourage
programmers to avoid deviding their work into appropriately selfcontained
objects. The also seem to encourage programmers to avoid using namespaces.

For me, they are simply one more point of confusion when trying to remember
all the rules of declaring and defining programming constructs. These
rules are not, to my knowledge isolated to a compact, accessible reference.
I find myself flipping through several chapters trying to find the answer
to specific questions regarding parameter assigning defaults to optional
parameters, and the like.

So, now that I''ve said a lot of bad things about the language, let me
mention something I really like, though they are still new to me. Functors
are cool!

STH

推荐答案

Hattuari写道:
Hattuari writes:
从这个意义上说,我会问一下好的头文件是什么。他们似乎只是对我的行政开销。我相信他们鼓励程序员避免将他们的工作分成适当的自包含对象。这似乎也鼓励程序员避免使用
命名空间。
对于我来说,当尝试
时,它们只是另一个混​​淆点,记住了声明和定义编程结构的所有规则。据我所知,这些
规则并不是一个紧凑的,可访问的
参考。我发现自己翻阅了几个章节,试图找到答案,关于参数分配默认为可选
参数等具体问题。
So in that sense, I will ask what good header files really are. They seem
to be nothing but administrative overhead to me. I believe they encourage
programmers to avoid deviding their work into appropriately selfcontained
objects. The also seem to encourage programmers to avoid using namespaces.
For me, they are simply one more point of confusion when trying to remember all the rules of declaring and defining programming constructs. These
rules are not, to my knowledge isolated to a compact, accessible reference. I find myself flipping through several chapters trying to find the answer
to specific questions regarding parameter assigning defaults to optional
parameters, and the like.




C ++中对头文件的需求比对C的头文件要少,因为

肯定是正确的。但他们仍然至少有两个重要的功能。

包容警卫和制作定制版程序。对于

示例:一种有三种形式的浏览器:瘫痪,因此无法发布

(对于图书馆而言),在许多其他方面都瘫痪(免费演示) )和一个

完整的铃声和口哨浏览器。



There is less need for header files in C++ than there is/was for C, that is
certainly true. But they still have at least two vital functions.
Inclusion guards and producing customized versions of programs. For
example: a browser that comes in three flavors: crippled so it can''t post
(for libraries), crippled in many other respects (for a free demo) and a
full bells and whistles browser.


2004年2月26日星期四06:49:03 -0500,Hattuari
< su ****** @ setidava.kushan.aa>写道:
On Thu, 26 Feb 2004 06:49:03 -0500, Hattuari
<su******@setidava.kushan.aa> wrote:
我在计算机行业工作了几年后,正在学习C ++,同时兼顾系统管理和工程。我已经用Perl,Bash,Pascal,Ada,C,Mathematica(数百行OO代码,而不是1 + 1),JavaScript,Lisp和Java编写代码,以及C ++。这些语言中的每一种都有它的优点和缺点。我使用C ++的经历告诉我,这是我学习中最难的。


完全学习是非常困难的。学习足以开始写作

有用的程序非常简单(尝试加速C ++,由Koenig和

Moo)。

我有这样的感觉C ++中的一些功能是不必要的,而且服务器没什么用处。尽管如此,它们确实增加了复杂性,从而增加了学习语言的难度。我知道
有很多用这种语言编写的优秀软件。
也许我没有准确地感知事物,但我觉得C ++正在失去对其他人的重要地位。语言,特别是Java。


我认为Java最近已经失去了很多基础 - 几年前它有一个巨大的繁荣,但是增长已经停止。正如我所理解的那样,C ++的需求肯定会增加,但是b $ b正在稳步增加。


正在搜索Java和C ++在你最喜欢的求职搜索引擎中是一个很好的方法来获得一个粗略的想法。

所以在这个意义上,我会问一下好的头文件是什么。他们似乎只是对我的行政开销。我相信他们鼓励程序员避免将他们的工作分成适当的自包含对象。这似乎也鼓励程序员避免使用命名空间。


头文件(以及整个预处理器)是一个不幸的结果来自C的结转。在C中它们比在C ++中更有意义,因为C

没有深奥的名称查找,重载和模板

实例化C ++。


某种代码模块/数据库系统会更好,虽然我认为人们会厌恶放弃预处理器,但是很多

它使得连续代码分析器的工作(如现代使用的那样) Java

像Eclipse和IntelliJ IDEA这样的IDE更难有效地工作。

对我来说,在尝试记住时,它们只是一个混乱点声明和定义编程结构的规则。据我所知,这些
规则并不是一个紧凑的,可访问的参考资料。
我发现自己翻阅了几个章节试图找到关于参数赋值默认为可选的具体问题的答案
参数等。
I''m learning C++ after having spent several years in the computer industry
doing both system administration and engineering. I''ve written code in
Perl, Bash, Pascal, Ada, C, Mathematica (hundreds of lines of OO code, not
1+1), JavaScript, Lisp, and Java, as well as C++. Each of these languages
has it''s strengths and weaknesses. My experience with C++ has shown me
that it is by far the most difficult for me to learn.
Learning it completely is very hard. Learning enough to start writing
useful programs is quite easy (try Accelerated C++, by Koenig and
Moo).
I have the sense that some of the features in C++ are unnecessary, and
server little real purpose. None the less, they do serve to add to the
complexity, and hence the difficulty, of learning the language. I know
there is a good deal of excellent software written in the language.
Perhaps I''m not perceiving things accurately, but I have the sense that C++
is losing significant ground to other languages, expecially Java.
I think Java has lost a lot of ground recently - it had a huge boom a
few years ago but growth has stopped. C++ demand has surely but
steadily increased, as I understand it.

Searching for "Java" and "C++" in your favourite job search engine is
a good way to get a rough idea.
So in that sense, I will ask what good header files really are. They seem
to be nothing but administrative overhead to me. I believe they encourage
programmers to avoid deviding their work into appropriately selfcontained
objects. The also seem to encourage programmers to avoid using namespaces.
Header files (and the whole preprocessor) are an unfortunate
carry-over from C. In C they make more sense than in C++, since C
doesn''t have the esoteric name lookup, overloading and template
instantiation of C++.

Some kind of code module/database system would be better, although I
think people would be loathe to give up the preprocessor, however much
it makes the job of continuous code analyzers (as used in modern Java
IDEs like Eclipse and IntelliJ IDEA) much harder to do efficiently.
For me, they are simply one more point of confusion when trying to remember
all the rules of declaring and defining programming constructs. These
rules are not, to my knowledge isolated to a compact, accessible reference.
I find myself flipping through several chapters trying to find the answer
to specific questions regarding parameter assigning defaults to optional
parameters, and the like.




您可以随时询问 - 答案通常只需几分钟即可显示

。或者,学习特定参考书的方式

书(例如The C ++ Programming Language)可能会有所帮助 - 它会更容易找到你的'b $ b'正在寻找。


Tom

-

C ++ FAQ: http://www.parashift.com/c++-faq-lite/

C常见问题: http://www.eskimo.com/~ scs / C-faq / top.html





我同意。当我想使用一些特定的C ++实体时,我应该告诉这个实体的名字是

,而不是一些奇怪的包含文件的名称。例如:


而不是:


#include< fstream>

//使用std :: ifstream


,例如,这个:


包括std :: ifstream;

//使用std :: ifstream;


头文件很难看,因为它们不是语言的一部分 - 它们

生活在一个完全不同的命名空间中,具有不同的规则(这是

系统依赖)。他们会在编程时引入另一组不必要的名称和

规则。它们很危险,因为很少b $ b知道他究竟包括什么。特别是当使用比STL更低标准的
库时。


它们永远不应被禁止(因为宏不是),但它们不应该是

整个C ++编程的基础,就像现在一样。


亲切的问候,

Marcin


Uzytkownik" Hattuari" <苏****** @ setidava.kushan.aa> napisal w wiadomosci

新闻:L6 ******************** @ speakeasy.net ...

我在计算机行业工作了几年后学习C ++

同时进行系统管理和工程。我已经编写了代码

Perl,Bash,Pascal,Ada,C,Mathematica(数百行OO代码,而不是
1 + 1),JavaScript, Lisp,Java,以及C ++。这些语言中的每一种都有它的优点和缺点。我使用C ++的经历告诉我

这是我学习中最困难的。


我有一些感觉C ++是不必要的,而且
服务器没什么用处。尽管如此,它们确实增加了学习语言的复杂性,从而增加了学习语言的难度。我知道

有很多用这种语言编写的优秀软件。

也许我没有准确地感知事物,但我感觉C ++

正在失去其他语言的重要地位,特别是Java。


我不太确定为什么我有动力去学习这门课程,但我有a

真正希望确定C ++的哪一部分可以从语言的整个部分中提取出来,并以某种方式进行修改,并仍然提供

几乎所有当前语言的功能。无视

Stroustrup对莎士比亚的解释,我相信这可能是一项很好的运动,而b
基本上是将这种语言用于审判。也许这样的事情已经完成了。我正在谈论一个sicere批评,而不是一个情绪化的攻击。<​​br />

所以从这个意义上说,我会问什么是好的头文件。他们似乎只是对我来说是行政开销。我相信他们鼓励

程序员避免将他们的工作分成适当的自包含对象。这似乎也鼓励程序员避免使用名称空间。


对我而言,当他们试图记住

所有的规则时,他们只是另一个混​​乱点。声明和定义编程结构。据我所知,这些

规则并不是一个紧凑的,可访问的参考资料。

我发现自己翻了几章试图找到答案

有关参数分配的具体问题默认为可选的

参数等。


所以,现在我已经说了很多坏事关于这门语言的事情,让我来说,b $ b提到我真正喜欢的东西,虽然它们对我来说还是新手。玩家

很酷!


STH
Hi,

I agree. When I want to use some specific C++ entity, I should tell name of
this entity, not name of some weird include file. For example:

Instead of:

#include <fstream>
// use std::ifstream

do, for example, this:

include std::ifstream;
// use std::ifstream;

Header files are ugly because they are not a part of the language - they
live in a completely different namespace, with different rules (which are
system dependent). They introduce another, unneccesary set of names and
rules to remember when programming. They are dangerous, because one seldom
knows what he exactly includes. Especially when using less-standarized
libraries than STL is.

They should never be banned (as macros were not), but they should not be a
foundation of whole C++ programming, as they are now.

Kind regards,
Marcin

Uzytkownik "Hattuari" <su******@setidava.kushan.aa> napisal w wiadomosci
news:L6********************@speakeasy.net...
I''m learning C++ after having spent several years in the computer industry
doing both system administration and engineering. I''ve written code in
Perl, Bash, Pascal, Ada, C, Mathematica (hundreds of lines of OO code, not
1+1), JavaScript, Lisp, and Java, as well as C++. Each of these languages
has it''s strengths and weaknesses. My experience with C++ has shown me
that it is by far the most difficult for me to learn.

I have the sense that some of the features in C++ are unnecessary, and
server little real purpose. None the less, they do serve to add to the
complexity, and hence the difficulty, of learning the language. I know
there is a good deal of excellent software written in the language.
Perhaps I''m not perceiving things accurately, but I have the sense that C++
is losing significant ground to other languages, expecially Java.

I''m not really sure why I''m motivated to follow this course, but I have a
real desire to determine what part of C++ could be extracted from the
entire body of the language, modified in certain ways, and still provide
virtually all the capabilities of the current language. Disregarding
Stroustrup''s paraphrase of Shakespeare, I believe it might be fine sport to
basically put the language on trial. Perhaps such a thing has already been
done. I''m talking about a sicere critique, not an emotional attack.

So in that sense, I will ask what good header files really are. They seem
to be nothing but administrative overhead to me. I believe they encourage
programmers to avoid deviding their work into appropriately selfcontained
objects. The also seem to encourage programmers to avoid using namespaces.

For me, they are simply one more point of confusion when trying to remember
all the rules of declaring and defining programming constructs. These
rules are not, to my knowledge isolated to a compact, accessible reference.
I find myself flipping through several chapters trying to find the answer
to specific questions regarding parameter assigning defaults to optional
parameters, and the like.

So, now that I''ve said a lot of bad things about the language, let me
mention something I really like, though they are still new to me. Functors
are cool!

STH


这篇关于头文件真的有用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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