应该C ++消除头文件? [英] Should C++ eliminate header files?

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

问题描述

许多语言,例如Java,C#,不会将声明与实现分离。 C#有一个部分类的概念,但实现和声明仍然保留在同一个文件中。

Many languages, such as Java, C#, do not separate declaration from implementation. C# has a concept of partial class, but implementation and declaration still remain in the same file.

为什么C ++没有相同的模型?是否更实用的头文件?

Why doesn't C++ have the same model? Is it more practical to have header files?

我指的是当前和即将到来的C ++标准版本。

I am referring to current and upcoming versions of C++ standard.

推荐答案

我经常在C#和C ++之间翻转,C#中缺少头文件是我最大的宠物。我可以看一个头文件,并学习我需要知道的所有我需要知道一个类 - 它是成员函数被调用,它们的调用语法等 - 而不必涉及实现类的代码的页面。

I routinely flip between C# and C++, and the lack of header files in C# is one of my biggest pet peeves. I can look at a header file and learn all I need to know about a class - what it's member functions are called, their calling syntax, etc - without having to wade through pages of the code that implements the class.

是的,我知道部分类和#regions,但它不一样。部分类实际上使问题更糟,因为类定义分布在多个文件中。就#regions去,他们似乎没有以我想要的方式展开我目前正在做的,所以我必须花时间扩大这些小加号,直到我得到正确的视图。

And yes, I know about partial classes and #regions, but it's not the same. Partial classes actually make the problem worse, because a class definition is spread across several files. As far as #regions go, they never seem to be expanded in the manner I'd like for what I'm doing at the moment, so I have to spend time expanding those little plus's until I get the view right.

也许如果Visual Studio的intellisense更好地为C ++工作,我不会有一个令人信服的理由必须经常参考.h文件,但即使在VS2008,C ++的intellisense可以' t触摸C#的

Perhaps if Visual Studio's intellisense worked better for C++, I wouldn't have a compelling reason to have to refer to .h files so often, but even in VS2008, C++'s intellisense can't touch C#'s

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

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