C ++促进类定义和类实现之间的分离,而不是JAVA [英] C++ promotes a separation between class definitions and class implementations but not JAVA

查看:133
本文介绍了C ++促进类定义和类实现之间的分离,而不是JAVA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个作业,我需要评估哪种方法更好根据GRASP。

I have a homework and I need to evaluate which approach is better according to GRASP.

我发现这个链接,回答了我的问题的一部分:在C ++中为什么有头文件和cpp文件?

I found this link that answers part of my questioning: In C++ why have header files and cpp files?

然而,我想知道的是多少c ++工作方式更好的可扩展性和代码重用比JAVA,因为一切都在一个联合文件中定义?

However, what I want to know is how much c++ way of working is better for extensibility and for code reuse than JAVA because everything is defined in a conjoint file ?

感谢您的帮助!

编辑:为了确保这不是一个辩论,我想知道为什么JAVA不喜欢在C和促进类定义和类实现之间的分离。

Just to make sure that this is not a debate, I want to know why does JAVA does not do like in C and promotes the separation between class definitions and class implementations. Are there any advantages with that way of working or proceding ?

此问题已移至http://programmers.stackexchange.com/questions/118574/does-java-promote-a-separation-between-类定义和实现 - 作为

推荐答案

在Java中的等价是你声明 class接口,用于实现无声明的目的。实现与接口的绑定确实在运行时发生

the equivalent in java is that you declare class interfaces that does serve the purpose of a implementation-less declaration. The binding of the implementation to the interface does happen at runtime

在可扩展性的意义上,两者都是完全等效的。两种语言之间的差异不在于可扩展性能力本身,而在于它们的性能方法。 Java和C#在它们的语法更统一,更简洁,而某些C ++可能是一个痛苦为初学者阅读。 C ++通过模板在编译时类型绑定方面有广泛的关注,而Java和C#传统上更关注运行时绑定和反射。虽然对于某些应用程序领域(主要是高性能计算)来说,垃圾收集等好的语言特性对于Java和C#仍然是一个高级的入口门槛,但这种差异在过去几年已经软化了。

in the sense of extensibility both are entirely equivalent. The differences between both languages do not lie in the extensibility capabilities themselves, but in their performance approaches. Java and C# are more uniform in their syntax and more terse, while certain C++ can be a pain to read for the beginner. C++ has extensive focus in compile-time type binding through templates, while java and C# have traditionally more focus on run-time binding and reflection. This difference has softened in the last years, although for some application domain niches (mainly high performance computing) nice language features like garbage collection are still a high barrier of entry for the likes of Java and C#

这篇关于C ++促进类定义和类实现之间的分离,而不是JAVA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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